(function() {
  "use strict";

  // Load Google Analytics libraries
  GOVUK.StaticAnalytics.load();

  // Use document.domain in dev, preview and staging so that tracking works
  // Otherwise explicitly set the domain as www.gov.uk (and not gov.uk).
  var cookieDomain = (document.domain == 'www.gov.uk') ? '.www.gov.uk' : document.domain;

  var universalId = 'UA-26179049-1';

  // Configure profiles, setup custom vars, track initial pageview
  var analytics = new GOVUK.StaticAnalytics({
    universalId: universalId,
    cookieDomain: cookieDomain,
    govukTrackerGifUrl: '<%= asset_path "/static/a.gif" %>',
  });

  // Make interface public for virtual pageviews and events
  GOVUK.analytics = analytics;
})();

(function(global) {
  "use strict";

  // Load Google Analytics libraries
  GOVUK.StaticAnalytics.load();

  // Use document.domain in dev, preview and staging so that tracking works
  // Otherwise explicitly set the domain as www.gov.uk (and not gov.uk).
  var cookieDomain = (document.domain == 'www.gov.uk') ? '.www.gov.uk' : document.domain;

  var universalId = 'UA-26179049-1';

  // Configure profiles, setup custom vars, track initial pageview
  var analytics = new GOVUK.StaticAnalytics({
    universalId: universalId,
    cookieDomain: cookieDomain,
    allowLinker: true,
    govukTrackerGifUrl: '<%= asset_path "/static/a.gif" %>',
  });

  // Make interface public for virtual pageviews and events
  GOVUK.analytics = analytics;

  if (global.ga) {
    var ga = global.ga;
    ga('require', 'linker');
    ga('linker:autoLink', ['planforbritain.gov.uk']);
  }
})(window);

Add linked domain tracking to Plan For Britain campaign
Add linked domain tracking to Plan For Britain campaign

Adds linked tracking without creating a new tracker, as per
https://developers.google.com/analytics/devguides/collection/analyticsjs
/linker. As this is a temporary measure, we’re calling `ga` directly
rather than adding the functionality to
`GOVUK.GoogleAnalyticsUniversalTracker` in `govuk_frontend_toolkit`.
