Reputation: 3334
Inspecting _utm.gif
I've determined the Extensible Parameter utme
is not being passed. I don't see it at all when I inspect it with Firebug. I'm trying to track an event with Google Analytics - a simple button click.
The Google code in <head>
.
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']); //in reality, this ID is set correctly
_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);
})();
</script>
<script type="text/javascript">
function recordOutboundLink(link, category, action) {
try {
var myTracker=_gat._getTrackerByName();
_gaq.push(['myTracker._trackEvent', ' + category + ', ' + action + ']);
setTimeout('document.location = "' + link.href + '"', 100)
}catch(err){}
}
</script>
The code I use in the <body>
<a onClick="recordOutboundLink(this, 'button', 'clicked');return false;" href="http://someoutboundlink.com">
<img src="http://some-image.png">
</a>
What am I missing? Why aren't my params button
and clicked
being passed in the _utm.gif
?
Upvotes: 0
Views: 1288
Reputation: 22832
Your function is wrong. Just because you named your tracker variable myTracker it's not the internal name of the tracker. In your case you use a nameless tracker. And the correct way to fire an event for it is just calling _trackEvent
.
function recordOutboundLink(link, category, action) {
try {
_gaq.push(['_trackEvent', category , action ]);
setTimeout('document.location = "' + link.href + '"', 100)
}catch(err){}
}
Upvotes: 1
Reputation: 3334
Figured it out.
My onClick
was incorrectly spelled onclick
in my real code. My example above is correct.
It's the little things.
EDIT My answer is incorrect. See the accepted answer above.
Upvotes: 0
Reputation: 14435
Could be the quotes issue in your track event call:
Try:
_gaq.push(['myTracker._trackEvent', category, action]);
Upvotes: 1