The Gotcha
Today I got an odd comment from a client: according to Google Analytics, he was getting zero search engine traffic. None. It was all direct traffic.
Now the site's not expected to get bombarded with traffic, but really, zero traffic?
My first thought was that the site wasn't in Google's and other's indexes - but a quick search for site:sitename.com showed me that it was.
Looking closer, I realized the only hits being counted were those where I have overridden the value to _trackPageView. Sure enough, I had gotten clever with the Google Analytics code and said:
<script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-XXX-1"); if(pageName) { pageTracker._trackPageview(pageName); } else { pageTracker._trackPageview(); } } catch(err) {alert(err)} </script>
That is, if the value of pageName is defined, then report that as the page viewed. Otherwise use the default name. This allows me to say:
<script type="text/javascript"> var pageName = '/player'; </script>
at the top of the page, and rather than having the default URL (say: index.php?action=player&value=foo.mp3) show up in Analytics the pretty /player shows up.
The problem, though, is that if pageName was left undefined, the entire block of code exited, and no page view was counted.
The problem was easy to fix - just change it to:
<script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-XXX-1"); if(typeof(pageName) != 'undefined') { pageTracker._trackPageview(pageName); } else { pageTracker._trackPageview(); } } catch(err) {} </script>
But still, I had managed to hose the up the Anaytics for the last week or so - and that was a bad thing.
The Lesson
The good news though, is that I wasn't the one who configured Analytics on the site (nope, I just broke it) - it was the folks at Silver Beacon Marketing who did that. And when I touched base with George at Silver Beacon, he let me in on a really valuable lesson:
When setting up the analytics for a site, always take the time to install a backup provider. That way, if either you or the provider mess things up, the client won't lose all their stats for the time period in question.
What a simple idea. But, oh so brilliant. George even had a few recommendations as to free/low cost Analytics providers you might want to use as a backup. They include:
Oh, and because Silver Beacon did the setup, they had multiple stat providers on there - and my goof was absolutely minimized. Whew.
No comments:
Post a Comment