Skip to content

Commit

Permalink
fix: tracking code
Browse files Browse the repository at this point in the history
  • Loading branch information
masnormen committed Feb 9, 2025
1 parent 21547d4 commit cb1c091
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions app/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,26 +111,22 @@ export const Route = createRootRoute({
src: `https://www.googletagmanager.com/gtag/js?id=${import.meta.env.VITE_GA_ID}`,
},
{
dangerouslySetInnerHTML: {
__html: `window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${import.meta.env.VITE_GA_ID}');`,
},
children: `window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${import.meta.env.VITE_GA_ID}');`,
},
]
: []),

...(import.meta.env.VITE_GTM_ID
? [
{
dangerouslySetInnerHTML: {
__html: `(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','${import.meta.env.VITE_GTM_ID}');`,
},
children: `(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','${import.meta.env.VITE_GTM_ID}');`,
},
]
: []),
Expand Down

0 comments on commit cb1c091

Please sign in to comment.