(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,
  });

  // 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);

(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,
    // This is served by Fastly in production, and returns an empty 200 response
    govukTrackerGifUrl: '<%= asset_path "/static/a" %>',
  });

  // 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);

Enable GOV.UK analytics tracker configuration
Enable GOV.UK analytics tracker configuration

The configuration variable is misnamed and will be changed once this is
proven to work. The endpoint is now served entirely by Fastly, and
returns an empty 200 response. We only call the endpoint using
`$.get()` and ignore the response so its Content-Type doesn’t matter.
