You can then create tags that wait for the gtm.linkClick event to happen, and perform additional tasks (like the external link tracker tag described below). note: There are a number of tagging strategies. You’d be able to see anytime someone who got your direct mail package in the mail, actually went to your website. This can be added to existing JavaScript files or in a script block as long as it’s loaded somewhere within the HTML body (ideally, just before the closing tag). jQuery (or your alternative) must be loaded first although the Google Analytics tracking code can appear anywhere on the page. /* Track outbound links in Google Analytics */ (function($) { "use strict"; // current page host var baseURI = window.location.host; // click event on body $("body").on("click", function(e) { // abandon if link already aborted or analytics is not available if (e.isDefaultPrevented() || typeof ga !== "function") return; // abandon if no active link or link within domain var link = $(e.target).closest("a"); if (link.length != 1 || baseURI == link[0].host) return; // cancel event and record outbound link e.preventDefault(); var href = link[0].href; ga('send', { 'hitType': 'event', 'eventCategory': 'outbound', 'eventAction': 'link', 'eventLabel': href, 'hitCallback': loadPage }); // redirect after one second if recording takes too long setTimeout(loadPage, 1000); // redirect to outbound page function loadPage() { document.location = href; } }); })(jQuery); // pass another library here if required The event is recorded with the category name ‘outbound’, action name ‘link’ and the value set to the URL of the outbound page.
When you are using HootSuite, you can shorten any URL to an ow.ly or ht.ly link. Therefore, as a Twitter marketer who needs to track link performance, you should use bit.ly. My third choice, which was once my first choice, is Bitly. Upgrade my links by putting my name in a custom domain and sharing with friends, family and on social media. One of the most commonly asked question was how to track links in WordPress using Google Analytics? See if you are using Classic Analytics (ga.js) or Universal Analytics (analytics.js).