Sha256: 6a3c5a41038157d7b7db78ca934383430985d91146b822614c1339747dbc0684

Contents?: true

Size: 1.03 KB

Versions: 13

Compression:

Stored size: 1.03 KB

Contents

window.GOVUK = window.GOVUK || {}
window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {}

var initFunction = function () {
  // to be added: digital identity consent mechanism

  var consentCookie = window.GOVUK.getConsentCookie()

  if (consentCookie && consentCookie.usage) {
    window.GOVUK.analyticsGa4.vars.internalDomains = []
    window.GOVUK.analyticsGa4.vars.internalDomains.push(window.GOVUK.analyticsGa4.core.trackFunctions.getHostname())
    window.GOVUK.analyticsGa4.core.trackFunctions.appendDomainsWithoutWWW(window.GOVUK.analyticsGa4.vars.internalDomains)
    window.GOVUK.analyticsGa4.core.load()

    var analyticsModules = window.GOVUK.analyticsGa4.analyticsModules
    for (var property in analyticsModules) {
      var module = analyticsModules[property]
      if (typeof module.init === 'function') {
        module.init()
      }
    }
    // to be added: cross domain tracking code
  } else {
    window.addEventListener('cookie-consent', window.GOVUK.analyticsGa4.init)
  }
}

window.GOVUK.analyticsGa4.init = initFunction

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
govuk_publishing_components-34.6.0 app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js
govuk_publishing_components-34.4.2 app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js
govuk_publishing_components-34.4.1 app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js
govuk_publishing_components-34.4.0 app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js
govuk_publishing_components-34.3.0 app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js
govuk_publishing_components-34.2.0 app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js
govuk_publishing_components-34.1.3 app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js
govuk_publishing_components-34.1.2 app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js
govuk_publishing_components-34.1.1 app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js
govuk_publishing_components-34.1.0 app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js
govuk_publishing_components-34.0.0 app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js
govuk_publishing_components-33.1.0 app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js
govuk_publishing_components-33.0.0 app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js