Skip to content

Commit

Permalink
Merge pull request #7598 from ministryofjustice/ctskf-941-ga-tags
Browse files Browse the repository at this point in the history
[CTSKF-941] Update Google Analytics Tags
  • Loading branch information
mpw5 authored Oct 24, 2024
2 parents 875b8a5 + 49d4be6 commit 19da363
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .k8s/live/api-sandbox/app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ data:
RAILS_SERVE_STATIC_FILES: only-presence-required-to-enable
GRAPE_SWAGGER_ROOT_URL: 'https://api-sandbox.claim-crown-court-defence.service.justice.gov.uk'
CASEWORKER_API_URL: 'http://cccd-app-service'
GA_TRACKER_ID: 'UA-37377084-48'
GA_TRACKER_ID: 'G-GK279GHP21'
MAINTENANCE_MODE: 'false'
SETTINGS__SLACK__BOT_NAME: 'Injectotron'
SETTINGS__SLACK__FAIL_ICON: ':katyperry:'
Expand Down
2 changes: 1 addition & 1 deletion .k8s/live/dev-lgfs/app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ data:
RAILS_SERVE_STATIC_FILES: only-presence-required-to-enable
GRAPE_SWAGGER_ROOT_URL: 'https://dev-lgfs.claim-crown-court-defence.service.justice.gov.uk'
CASEWORKER_API_URL: 'http://cccd-app-service'
GA_TRACKER_ID: 'UA-37377084-48'
GA_TRACKER_ID: 'G-GK279GHP21'
MAINTENANCE_MODE: 'false'
SETTINGS__SLACK__BOT_NAME: 'Injectotron'
SETTINGS__SLACK__FAIL_ICON: ':katyperry:'
Expand Down
2 changes: 1 addition & 1 deletion .k8s/live/dev/app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ data:
RAILS_SERVE_STATIC_FILES: only-presence-required-to-enable
GRAPE_SWAGGER_ROOT_URL: 'https://dev.claim-crown-court-defence.service.justice.gov.uk'
CASEWORKER_API_URL: 'http://cccd-app-service'
GA_TRACKER_ID: 'UA-37377084-48'
GA_TRACKER_ID: 'G-GK279GHP21'
MAINTENANCE_MODE: 'false'
SETTINGS__SLACK__BOT_NAME: 'Injectotron'
SETTINGS__SLACK__FAIL_ICON: ':katyperry:'
Expand Down
3 changes: 1 addition & 2 deletions .k8s/live/production/app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ data:
RAILS_SERVE_STATIC_FILES: only-presence-required-to-enable
GRAPE_SWAGGER_ROOT_URL: 'https://claim-crown-court-defence.service.gov.uk'
CASEWORKER_API_URL: 'http://cccd-app-service'
GA_TRACKER_ID: 'UA-37377084-37'
GTM_TRACKER_ID: 'GTM-NSB9GWK'
GA_TRACKER_ID: 'G-MRKGHQ51SQ'
MAINTENANCE_MODE: 'false'
SETTINGS__SLACK__BOT_NAME: 'Injectotron'
SETTINGS__SLACK__FAIL_ICON: ':katyperry:'
Expand Down
3 changes: 1 addition & 2 deletions .k8s/live/staging/app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ data:
RAILS_SERVE_STATIC_FILES: only-presence-required-to-enable
GRAPE_SWAGGER_ROOT_URL: 'https://staging.claim-crown-court-defence.service.justice.gov.uk'
CASEWORKER_API_URL: 'http://cccd-app-service'
GA_TRACKER_ID: 'UA-37377084-48'
GTM_TRACKER_ID: 'GTM-PNZFWQT'
GA_TRACKER_ID: 'G-GK279GHP21'
MAINTENANCE_MODE: 'false'
SETTINGS__SLACK__BOT_NAME: 'Injectotron'
SETTINGS__SLACK__FAIL_ICON: ':katyperry:'
Expand Down
32 changes: 15 additions & 17 deletions app/views/layouts/_analytics.js.haml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
- if adapter == :gtm
= javascript_tag nonce: true do
:plain
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer',"#{ENV['GTM_TRACKER_ID']}");
= javascript_tag nonce: true do
:plain
let googleTrackingID = "#{ENV.fetch('GA_TRACKER_ID', nil)}"

- if adapter == :ga
= javascript_tag nonce: true do
:plain
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', "#{ENV['GA_TRACKER_ID']}", 'auto');
ga('set', 'anonymizeIp', true);
const analyticsScriptTag = document.createElement('script')
analyticsScriptTag.async = ''
analyticsScriptTag.src = `https://www.googletagmanager.com/gtag/js?id=${googleTrackingID}`
document.head.appendChild(analyticsScriptTag)

window.dataLayer = window.dataLayer || []

function gtag() {
dataLayer.push(arguments)
}
gtag('js', new Date())
gtag('config', `${googleTrackingID}`)

0 comments on commit 19da363

Please sign in to comment.