Google has recently released Universal Analytics. as a closed developer preview public beta. You can create a new web property in Google Analytics to try it out or upgrade your existing Google Analytics account. The tracking code should be calling google-analytics.com/analytics.js as opposed to google-analytics.com/ga.js.
One of the best features for a developer I’ve found so far in my hour of playing around is the ability to have a callback method executed after you’ve sent some data.
The prime case would be when you would track a link as an event. You would use a setTimeout to trigger the clicked link after you’d hoped the event had been sent to Google. No more! You can now use the following piece of javascript utilising the hitCallback function:
var href = "http://www.domsammut.com/";
ga('send', 'event', {
'eventCategory' : 'Star Trek',
'eventAction' : 'Fire',
'eventLabel' : 'Phasers',
'eventValue' : 100,
'hitCallback' : function () {
document.location = href;
}
});



7 Comments