Skip to content

Commit

Permalink
fix gtag loading (get rid of async)
Browse files Browse the repository at this point in the history
  • Loading branch information
romgere committed Oct 24, 2023
1 parent 02cc67a commit e2cfc0e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/initializers/gtag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ export function initialize() {
return;
}

injectGtag();
initGtag();
}

async function injectGtag() {
const script = document.createElement('script');
script.setAttribute('src', `https://www.googletagmanager.com/gtag/js?id=${gTag.tag}`);
script.async = true;

script.onload = initGtag;

document.body.appendChild(script);
}

Expand All @@ -21,7 +22,6 @@ function initGtag() {
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${gTag.tag}');
`;

Expand Down

0 comments on commit e2cfc0e

Please sign in to comment.