Sha256: c03421881ff3b2daeea8b380d6ee7f923e298d1cba50326828990c3e2244b0b3
Contents?: true
Size: 1.01 KB
Versions: 17
Compression:
Stored size: 1.01 KB
Contents
(function() { "use strict"; GOVUK.analyticsPlugins = GOVUK.analyticsPlugins || {}; GOVUK.analyticsPlugins.externalLinkTracker = function () { var currentHost = GOVUK.analyticsPlugins.externalLinkTracker.getHostname(), externalLinkSelector = 'a[href^="http"]:not(a[href*="' + currentHost + '"])'; $('body').on('click', externalLinkSelector, trackClickEvent); function trackClickEvent(evt) { var $link = getLinkFromEvent(evt), options = {transport: 'beacon'}, href = $link.attr('href'), linkText = $.trim($link.text()); if (linkText) { options.label = linkText; } GOVUK.analytics.trackEvent('External Link Clicked', href, options); } function getLinkFromEvent(evt) { var $target = $(evt.target); if (!$target.is('a')) { $target = $target.parents('a'); } return $target; } } GOVUK.analyticsPlugins.externalLinkTracker.getHostname = function() { return window.location.hostname; } }());
Version data entries
17 entries across 17 versions & 1 rubygems