Sha256: 610fd74441d8f81167880fe6a9f145db1acfac94466bc818a2e4a8fec6f89c93

Contents?: true

Size: 845 Bytes

Versions: 6

Compression:

Stored size: 845 Bytes

Contents

(function($) {
  function trackLinkClick(action, $element) {
    var linkText = $.trim($element.text());
    var linkURL = $element.attr('href');
    var label = linkText + '|' + linkURL;

    ga(
      'send',
      'event',
      'SM Technical Documentation', // Event Category
      action, // Event Action
      label // Event Label
    );
  }

  function linkTrackingEventHandler(action) {
    return function() {
      trackLinkClick(action, $(this));
    };
  };

  $(document).on('ready', function() {
    if (typeof ga === 'undefined') {
      return;
    }

    $('.technical-documentation a').on('click', linkTrackingEventHandler('inTextClick'));
    $('.header a').on('click', linkTrackingEventHandler('topNavigationClick'));
    $('.toc a').on('click', linkTrackingEventHandler('tableOfContentsNavigationClick'));
  });
})(jQuery);

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
govuk_tech_docs-1.4.0 lib/assets/javascripts/_analytics.js
govuk_tech_docs-1.3.1 lib/assets/javascripts/_analytics.js
govuk_tech_docs-1.3.0 lib/assets/javascripts/_analytics.js
govuk_tech_docs-1.2.0 lib/assets/javascripts/_analytics.js
govuk_tech_docs-1.1.0 lib/assets/javascripts/_analytics.js
govuk_tech_docs-1.0.0 lib/assets/javascripts/_analytics.js