Google Analytics - Outbound Link Tracking

Card Puncher Data Processing

Google Analytics - Outbound Link Tracking

About

hyperlink tracking with Google Analytics (ga)

Steps

Snippet

Based on the Capture outbound links documentation, this site capture all external link created with a anchor with this snippet.

jQuery(function () {
	jQuery('a.urlextern, a.interwiki').click(function () { // urlextern and interwiki are classes set for outbound link that we want to track
		var url = this.href;
		if(ga && ga.loaded){
			e.preventDefault();
			ga('send', 'event', 'outbound', 'click', url, {
				'transport': 'beacon',
				'hitCallback': function(){
                                // Doc: https://developers.google.com/analytics/devguides/collection/analyticsjs/sending-hits#hitcallback
                                if (target !== '_blank') {
                                document.location = url;
                                }
                            }
			});
		}
	});
});

Report

In google analytics, you can see them in the behavior section.

Example with the outbound links to amazon

Google Analytics Outbound Amazon





Discover More
HTML - A element (anchor)

HTML The a (or anchor) is a html element that represents a hyperlink. It is the cornerstone: of every navigation scheme on the web. and of the importance of a page on the internet (pagerank) ...
HTML - Hyper(Link) (href elements)

A link in HTML is an element that have the href attributes with an URL value An hyperlink is a contraction of hypertext link. link element The following elements are hyperlink because they have the...



Share this page:
Follow us:
Task Runner