homepage Welcome to WebmasterWorld Guest from 54.204.128.190
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / WebmasterWorld / Website Analytics - Tracking and Logging
Forum Library, Charter, Moderators: Receptional & mademetop

Website Analytics - Tracking and Logging Forum

    
Problem recording outbound links
Using Google code sample for Event Tracking
coopster




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

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:
https://support.google.com/analytics/bin/answer.py?hl=en&answer=1136920&topic=1136919&ctx=topic

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?

 

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / Website Analytics - Tracking and Logging
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved