So you want to be a GA expert, heh?

As you wish… But hang on, ’cause this might hurt ye ol’ brain a bit…

Tracking custom variables

How can you track custom variables with our Web Analytics Connector? It’s quite simple, actually. You need to wait for our tracking object to be created, and then you can do whatever you want with it – including setting custom variables! So how would that work? Well, as we saw before, we give you a nifty hook to customize the tracker object before we send the page view to GA – that is the best place to set your custom variables:

function monitus_customize_ga_tracker(pageTracker) {
pageTracker._setCustomVar(2,"My variable","The value",3);
}

Of course you’ll need to change the actual parameters to the _setCustomVar call, based on your needs, and the official Google Analytics custom variables documentation.

"onclick" tracking

Still around? All right – so how would you adapt the monitus code to track "onclick" events – say for event tracking? Again, it’s relatively simple… All you need is the name of our tracking object, and to avoid any possible javascript error from popping up, surround everything in a try block:

<a href="..." onclick="try{ _MONITUS.pageTracker._trackEvent("My Category", "My Action", "My Optional Label", "My Optional Value") }catch(e){};">My tracked link!</a>

Again, you’ll need to change the actual parameters to the _trackEvent call, based on your needs, and the official Google Analytics events documentation.