Skip to content

Commit

Permalink
fix/ga4-tag (#446)
Browse files Browse the repository at this point in the history
* Update gulpfile.js
  • Loading branch information
laurenhitchon authored and oisa committed Sep 13, 2024
1 parent c2be199 commit f0a97eb
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,24 +309,16 @@ function renamePathForProd() {

function addAnalytics() {
return src(`${config.dir.build}/**/*.html`)
.pipe(inject.after('<head>', `<script>(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','GTM-P2NKBBJZ');</script>
`))
.pipe(inject.after('<head>', `<script async src="https://www.googletagmanager.com/gtag/js?id=G-49T9M12F86"></script>
.pipe(inject.after('<head>', `
<script async src="https://www.googletagmanager.com/gtag/js?id=G-49T9M12F86"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-49T9M12F86');
</script>
`))
.pipe(inject.after('<body>', `<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-P2NKBBJZ"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
`))
`))
.pipe(dest(config.dir.build))
}

Expand Down

0 comments on commit f0a97eb

Please sign in to comment.