Welcome to WebmasterWorld Guest from 54.144.68.27

Forum Moderators: DixonJones & mademetop

Message Too Old, No Replies

Problem recording outbound links

Using Google code sample for Event Tracking

     

coopster

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

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



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?
 

Featured Threads

Hot Threads This Week

Hot Threads This Month