diff --git a/app/assets/javascripts/analytics.js.erb b/app/assets/javascripts/analytics.js.erb index 3cfc2a26d..b3e6c9e0b 100644 --- a/app/assets/javascripts/analytics.js.erb +++ b/app/assets/javascripts/analytics.js.erb @@ -149,19 +149,19 @@ var gtm_id = '<%= ENV["GOOGLE_TAG_MANAGER_ID"] %>' || null var gtag_id = '<%= ENV["GTAG_ID"] %>' || null if (gtm_id || gtag_id) { - if (typeof window.GOVUK.analyticsGA4.init !== 'undefined') { - window.GOVUK.analyticsGA4 = window.GOVUK.analyticsGA4 || {} - window.GOVUK.analyticsGA4.vars = window.GOVUK.analyticsGA4.vars || {} - window.GOVUK.analyticsGA4.vars.gem_version = '<%= GovukPublishingComponents::VERSION %>' + if (typeof window.GOVUK.analyticsGa4.init !== 'undefined') { + window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {} + window.GOVUK.analyticsGa4.vars = window.GOVUK.analyticsGa4.vars || {} + window.GOVUK.analyticsGa4.vars.gem_version = '<%= GovukPublishingComponents::VERSION %>' if (gtag_id) { - window.GOVUK.analyticsGA4.vars.gtag_id = gtag_id + window.GOVUK.analyticsGa4.vars.gtag_id = gtag_id } else { - window.GOVUK.analyticsGA4.vars.id = gtm_id - window.GOVUK.analyticsGA4.vars.auth = '<%= ENV["GOOGLE_TAG_MANAGER_AUTH"] %>' - window.GOVUK.analyticsGA4.vars.preview = '<%= ENV["GOOGLE_TAG_MANAGER_PREVIEW"] %>' + window.GOVUK.analyticsGa4.vars.id = gtm_id + window.GOVUK.analyticsGa4.vars.auth = '<%= ENV["GOOGLE_TAG_MANAGER_AUTH"] %>' + window.GOVUK.analyticsGa4.vars.preview = '<%= ENV["GOOGLE_TAG_MANAGER_PREVIEW"] %>' } - window.GOVUK.analyticsGA4.init() + window.GOVUK.analyticsGa4.init() } }