July 29, 2009 at 10:40 pm
filed under Web, Web Analytics, Web Design
Tagged burke, google analytics, issues, javascript, problems, The Grok, twitter
Note: feel free to ping me or leave a comment if you are having major issues!
Yesterday the event tracking on a site was not working, and someone thought it might be that I had missed a call to the ga.js file or some extra Javascript. My first thought was “This is why I hate Javascript.” That thought recurred throughout my investigation process, but I decided to save some people time and effort by posting a few things you could check before giving up and crying. My particular example was an onClick event, but the same things could apply to other situations.
Example: onclick=”pageTracker._trackEvent(“Foo”,”Bar”,”JS”);” This will be wrong because you have double quotation marks instead of apostrophes within the parentheses. So the page will read it as “pageTracker.trackEvent(” which will not do anything. Fix it like this: onclick=”pageTracker._trackEvent(‘Foo’,'Bar’,'JS’);”.
try {
var pageTracker = _gat._getTracker(“UA-xxxxxx-x”);
pageTracker._trackPageview();
} catch(err) {}
As much as I hate debugging JS, I think it has really helped me to have knowledge of how it works, so if this is all kinds of confusing, try working through the W3C tutorials.
The Grok delivers!! I was tweeting with @TheGrok and I asked if there was any way he could post about web analytics for non-profits. Brendan Regan wrote an awesomely helpful post about it. I will probably comment more about it later, but still, very cool.
And for those who use Twitter, #wa is being deprecated in favor of #measure. See Web Analytics Demystified for an explanation.
Related posts:
Having issues with event tracking in Google Analytics? Read on …- SFWEBDESIGN.com
on July 30, 2009 at 1:04 am
[...] the rest here: Having issues with event tracking in Google Analytics? Read on … Tags: event, file-or-some, not-working, some-extra, the-event, the-ga-js, thought-it-might, [...]
Rob
on August 2, 2009 at 6:25 pm
Hey Sarah,
Yeah, JS can be a pain at times. I must use your tips and give event tracking a go though.
Another very handy Firefox-based debugger is Firebug https://addons.mozilla.org/en-US/firefox/addon/1843 Does the same stuff as Web Developer’s Toolbar, but its CSS Inspector is much better and clearer.
Phil
on May 12, 2010 at 4:56 pm
Hi Sarah,
Thanks for the helpful article!
I was having a similar problem with my event tracking. What eventually solved it for me, was putting pageTracker._initData(); just before the pageTracker._trackPageview(); method call.
So like:
pageTracker._initData();
pageTracker._trackPageview();
Apparently this does something?! Anyways, thought this could be useful for others who come across this.
Cheers,
Phil
ps
on June 19, 2010 at 4:15 am
i came here looking for answers to my event tracking woes. i actually modified nothing, and maybe that was my problem? i notice in the line
var pageTracker = _gat._getTracker(“UA-xxxxxx-x”);
there are quotemarks, except when i changed them to single quote marks
var pageTracker = _gat._getTracker(‘UA-xxxxxx-x’);
then, my code seemed to work! umm… do you know why that might be?