Reputation: 2397
I made slight changes to the code described here in order to track outbound link clicks. This is my code:
function recordOutboundLink(link, label) {
try {
var myTracker=_gat._getTrackerByName();
_gaq.push(['myTracker._trackEvent', 'Outbound Links', label, link.href ]);
setTimeout('document.location = "' + link.href + '"', 100)
}catch(err){}
}
Then I added it to my href tags like so:
<a href="http://example.com/user/5" onclick="recordOutboundLink(this, 'example.com');return false"></a>
I think it's not working, though. It's really hard to check if it works or not. How do I check if it's working or not?
EDIT: Using google analytics debugger for chrome I was able to see what's going on. It displays:
Account ID : UA-XXXXX-X
It's odd because normal page tracking is working as expected. This is how I set up google analytics code:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'my-id']);
_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);
})();
Upvotes: 15
Views: 35940
Reputation: 11
You will also have to make sure that your tag is inserted in all of your pages. Here's a free service that can do that: http://www.tagcheckr.com Hope this helps.
Upvotes: 0
Reputation: 7314
In Chrome:
Look for:
Upvotes: 2
Reputation: 19
You can take a look at James for Chrome it's simple and free, we wrote is to debug our internal tool but made it available to all
Upvotes: 0
Reputation: 2397
Using google analytics tracking code debugger which @mike pointed out I was able to figure out that, although http://support.google.com/analytics/bin/answer.py?hl=en&answer=1136920 tells us to use
var myTracker=_gat._getTrackerByName();
_gaq.push(['myTracker._trackEvent', 'Outbound Links', label, link.href ]);
does not longer work, and one should use
_gaq.push(['_trackEvent', 'Outbound Links', label, link.href ]);
instead.
Upvotes: 0
Reputation: 7167
Look for the __utm.gif
tracking pixel request. A few different ways of doing this are:
The analytics code on the page probably has a _trackPageview, so as the page loads you'll see an initial __utm.gif.
When _trackEvent fires, there should be a new __utm.gif request being made. Parameters to examine in __utm.gif URL are:
Also, (as pointed out by @Eduardo), take a look at Google Analytics Basic Debugging
Upvotes: 20