Skip to content

Commit

Permalink
Merge pull request #2892 from alphagov/Update_GA4_naming_conventions
Browse files Browse the repository at this point in the history
Update analyticsGA4 naming convention
  • Loading branch information
JamesCGDS authored Sep 27, 2022
2 parents 6e12936 + cd8f690 commit 882029f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions app/assets/javascripts/analytics.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

0 comments on commit 882029f

Please sign in to comment.