Question

I got a issue with google analytics event track. The onclick event is only wokring in mozilla and internet explorer, i use a class on each buton "ga-track" and on the onclick event i send the ga.push track. I try switching between universal analytics and but it doesnt work

jQuery('.ga-track').on("click", function(){
    var theHREF = jQuery(this).attr('href');      
    _gaq.push(['_trackEvent', 'media', 'download', theHREF]);
});

Any clue?

Was it helpful?

Solution

Could be that the event has enough time to send in Mozilla, but not in WebKit.

Try using hitCallback which will wait until the event is sent before the next page loads:

jQuery('.ga-track-isa').on('click', function(e){
    e.preventDefault();
    var theHREF = jQuery(this).attr('href');

    _gaq.push(['_set', 'hitCallback', function(){
        window.location.href = theHREF;
    }]);

    _gaq.push(['_trackEvent', 'media', 'download', theHREF]);
}); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top