How to track links in Google analytics

?Track links in Google analytics?

It is very important for web developer and website owner to track ‘links clicked by user’. So it’s now easier to track links in website by Google analytics. Google analytics has few strong and precise mechanism to track links.

We will see how Google Analytics Event Tracking works. Because this link tracking system use google analytics event tracking method.

Place the following link before ending your <head> tag.

<script type="text/javascript">
$(document).ready(function(){
$('a').click(function(){
_gaq.push(['_trackEvent', 'UserProfile', 'Click', $(this).text()]);
_gaq.push(['_setCustomVar',1,'UserProfile','ProfileLayout','UserName']);
});
});
</script>

 

 

Now all links which will be clicked now are being tracked by our pretty simple jquery code. [Remember: don’t forget to add the Google Analytics code before </html>]

When a user will click on any links of the page then our code will be triggered and Google analytics will track that events. Then you can see the event report from ‘Content’->’Event’.

Shaharia is a professional software engineer with more than 10 years of experience in the relevant fields. Digital ad certified, cloud platform architect, Big data enthusiasts, tech early adopters.

Site Footer