Skip to content

Commit 0ed7b00

Browse files
committed
fix: Make analytics work again
1 parent e731344 commit 0ed7b00

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/layout/Dialogs/ConsentDialog.svelte

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@
99
1010
function enableAnalytics() {
1111
//@ts-ignore
12-
window.dataLayer = window.dataLayer || [];
13-
function gtag(...args: any[]) {
14-
//@ts-ignore
15-
window.dataLayer.push(args);
16-
}
17-
gtag('js', new Date());
12+
window.dataLayer = [
13+
{
14+
'gtm.start': new Date().getTime(),
15+
event: 'gtm.js'
16+
}
17+
];
18+
19+
var script = document.createElement('script');
20+
script.async = true;
21+
script.src = 'https://www.googletagmanager.com/gtm.js?id=' + RV_GOOGLE_TAG_MANAGER_ID;
1822
19-
const script = document.createElement('script');
20-
script.src = `https://www.googletagmanager.com/gtm.js?id=${RV_GOOGLE_TAG_MANAGER_ID}`;
21-
document.head.append(script);
23+
//@ts-ignore
24+
document.getElementsByTagName('script')[0].parentNode.insertBefore(script, firstScript);
2225
}
2326
2427
function handleConsent(allowed: boolean) {

0 commit comments

Comments
 (0)