BLOG-112 Add Google Analytics integration and update environment variables #113

Merged
squid merged 2 commits from BLOG-112_install_ga into main 2025-08-04 07:29:10 +08:00
2 changed files with 6 additions and 7 deletions
Showing only changes of commit e9b716521d - Show all commits

View File

@ -18,7 +18,6 @@ declare global {
interface Window {
dataLayer: unknown[];
gtag: (command: 'config' | 'set' | 'js' | 'event', ...args: unknown[]) => void;
}
}

View File

@ -1,4 +1,4 @@
<script lang="ts">
<script>
import { Environment } from '$lib/environment';
import { onMount } from 'svelte';
@ -19,10 +19,10 @@
document.head.appendChild(gaScript);
window.dataLayer = window.dataLayer || [];
window.gtag = (command: 'config' | 'set' | 'js' | 'event', ...args: unknown[]) => {
window.dataLayer.push(command, ...args);
};
window.gtag('js', new Date());
window.gtag('config', gaMeasurementId);
function gtag() {
window.dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', gaMeasurementId);
});
</script>