so the code I have is very basic and looks like this…
jQuery(document).ajaxSuccess(function(e, xhr, opt){
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'xxxx']);
_gaq.push(['_trackPageview', '/goal1']);
});
I have this in my footer
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'xxxx']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
And yet it does not work, any suggestions on how i could get this to work is appreciated, also I did a alert to make sure the ajax success works and it worked so i am 100% positive it should work.
you’ll have to write it this way
Else, _gaq is undefined at this point because of variable Hoisting in Javascript.