BLOG-112 refactor: simplify Google Analytics script initialization and remove gtag declaration from Window interface
This commit is contained in:
parent
db74a9b166
commit
09bae1126f
1
frontend/src/app.d.ts
vendored
1
frontend/src/app.d.ts
vendored
@ -18,7 +18,6 @@ declare global {
|
|||||||
|
|
||||||
interface Window {
|
interface Window {
|
||||||
dataLayer: unknown[];
|
dataLayer: unknown[];
|
||||||
gtag: (command: 'config' | 'set' | 'js' | 'event', ...args: unknown[]) => void;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<script lang="ts">
|
<script lang>
|
||||||
import { Environment } from '$lib/environment';
|
import { Environment } from '$lib/environment';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
@ -19,10 +19,10 @@
|
|||||||
document.head.appendChild(gaScript);
|
document.head.appendChild(gaScript);
|
||||||
|
|
||||||
window.dataLayer = window.dataLayer || [];
|
window.dataLayer = window.dataLayer || [];
|
||||||
window.gtag = (command: 'config' | 'set' | 'js' | 'event', ...args: unknown[]) => {
|
function gtag() {
|
||||||
window.dataLayer.push(command, ...args);
|
window.dataLayer.push(arguments);
|
||||||
};
|
}
|
||||||
window.gtag('js', new Date());
|
gtag('js', new Date());
|
||||||
window.gtag('config', gaMeasurementId);
|
gtag('config', gaMeasurementId);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user