Sha256: c0c88461c6af3be4d64f4db544ccf4cffae7c5053467bac8f2f934fe4795dbfb

Contents?: true

Size: 759 Bytes

Versions: 6

Compression:

Stored size: 759 Bytes

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.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

6 entries across 6 versions & 1 rubygems

Version Path
govuk_publishing_components-30.7.3 app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js
govuk_publishing_components-30.7.2 app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js
govuk_publishing_components-30.7.1 app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js
govuk_publishing_components-30.7.0 app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js
govuk_publishing_components-30.6.1 app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js
govuk_publishing_components-30.6.0 app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js