logo
Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
markphilips  
#1 Posted : Thursday, December 5, 2013 10:00:29 AM(UTC)
Guest

Rank: Guest

Groups: Guest
Joined: 9/17/2008(UTC)
Posts: 66

Sometimes you would like to track outbound clicks on a website. This is called tracking events. To track events we need to add additional code in the outgoing <a href>. But first we need to add some additional Google script to our <head> section (under the normal tracking code).

Paste this code under the main GA tracking code:

Code:
<script type="text/javascript">
function trackOutboundLink(link, category, action) { 
 
try { 
_gaq.push(['_trackEvent', category , action]); 
} catch(err){}
 
setTimeout(function() {
document.location.href = link.href;
}, 100);
}
</script>


Then add in each outbound link you want to track the next onclick function.

Code:
<a href="www.test.com" onClick="trackOutboundLink(this, '{Category}', '{Title}'); return false;">test</a>


For category you can use terms like outbound click or something; the title describes de link for example the name of the url you are going to link to.

In Google Analytics you will see the outbound links in the 'Events' report.

Wanna join the discussion?! Login to your Sienn Forum forum account. New Registrations are disabled.

markphilips  
#2 Posted : Thursday, December 5, 2013 10:02:36 AM(UTC)
Guest

Rank: Guest

Groups: Guest
Joined: 9/17/2008(UTC)
Posts: 66

if this function doesn't work:

Code:
<a href="www.test.com" onClick="trackOutboundLink(this, '{Category}', '{Title}'); return false;">test</a>


you might try

Code:
<a href="www.test.com" onClick="recordOutboundLink(this, '{Category}', '{Title}'); return false;">test</a>
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.