Welcome to WebmasterWorld Guest from 54.163.39.19

Forum Moderators: DixonJones & mademetop

Message Too Old, No Replies

Problem recording outbound links

Using Google code sample for Event Tracking

     
6:41 pm on Jan 4, 2013 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12548
votes: 2


Has anybody ever tried using this Google code snippet for tracking outbound links?

<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>


And your link:

<a href="http://www.example.com" onClick="recordOutboundLink(this, 'Outbound Links', 'example.com');return false;">


Resource:
[support.google.com...]

I have everything working now by replacing the push() method ...

<script type="text/javascript"> 
function recordOutboundLink(link, category, action) {
try {
//var myTracker=_gat._getTrackerByName();
//_gaq.push(['myTracker._trackEvent', category , action ]);
_gaq.push(['_trackEvent', category, action]);
setTimeout('document.location = "' + link.href + '"', 100)
}catch(err){}
}
</script>


... so that it is not attempting to get and use the tracker specifically. My question, any idea why it may not be working with that code in place?
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members