
Re: Automatic tracking of outbound links?
Yup, found it!
It's posted on this site:
http://www.jhuskisson.com/code-tidbits/ ... omaticallybut I'll give a quick overview...
Basically you have to paste the following code behind the normal ga.js tracker code, you get from google
the code:
Code:
<script type=”text/javascript”>
if (document.getElementsByTagName) {
var ahrefs = document.getElementsByTagName(’a');
for (var i=0; i<ahrefs.length;i++) {
if (ahrefs[i].href.indexOf(’http://www.domain.com’) == -1 && !ahrefs[i].onclick) {
ahrefs[i].onclick = function () {
pageTracker._trackPageview(’/outbound/’+this.href.substring(7));}
}}}
</script>
Then change the damain and you should be set. It will parse your fila and attach the _trackPageview to each link. Then in GA you will get the outbound links as:
yoursite.com/outbound/www.the-outbound-url.com
So it will not replicate the outbound link excatly but with some smart segmentation you can see how many hits the outbound folder gets and then to which url they go.
For the old urchin google code, urchinTracker, there's this version (but you should probably upgrade, if you still have the old version):
Code:
<script type=”text/javascript”>
if (document.getElementsByTagName) {
var ahrefs = document.getElementsByTagName(’a');
for (var i=0; i<ahrefs.length;i++) {
if (ahrefs[i].href.indexOf(’http://www.yourdoamin.com‘) == -1 && !ahrefs[i].onclick) {
ahrefs[i].onclick = function () { var track = this.href + ”; urchinTracker (’/outbound/’+track.substring(7)); }
}}}
</script>
Hope this helps, and tell me if it really works!