Skip to content

Commit

Permalink
apply conditional logic for "dataLayer" snippet to only show in ETA a…
Browse files Browse the repository at this point in the history
…nd not other forms
  • Loading branch information
ChisomOguibe11 committed Oct 17, 2023
1 parent df86adb commit e0d5ccc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions frontend/template-partials/views/partials/head.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{#gtmTagId}}
{{#cookiesAccepted}}
{{#isETA}}
<!-- Google Tag Manager Data Layer for ETA -->
<script {{#nonce}}nonce="{{nonce}}"{{/nonce}}>
var dataLayer = window.dataLayer || [];
Expand All @@ -11,16 +12,17 @@
});
</script>
<!-- End Google Tag Manager Data Layer for ETA -->
{{/isETA}}

<!-- Google Tag Manager for ETA -->
<!-- Google Tag Manager -->
<script {{#nonce}}nonce="{{nonce}}"{{/nonce}}>
(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','{{gtmTagId}}');
</script>
<!-- End Google Tag Manager for ETA -->
<!-- End Google Tag Manager -->
{{/cookiesAccepted}}
{{/gtmTagId}}

Expand Down
1 change: 1 addition & 0 deletions lib/ga-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module.exports = (app, config) => {
app.use((req, res, next) => {
const page = pageView(req.path, pageMap);
res.locals.gaAllowDebug = config.env === 'development';
res.locals.isETA = config.appName === 'ETA';
res.locals.gaTagId = gaTagId;
res.locals.ga4TagId = ga4TagId;
res.locals.gtmTagId = gtmTagId;
Expand Down

0 comments on commit e0d5ccc

Please sign in to comment.