<script lang="ts">
export let log_lvl: number = 0;

export let site_google_tracking_id: string = '';
if (log_lvl) {
    console.log(`AE Analytics: site_google_tracking_id = `, site_google_tracking_id);
}

if (typeof window !== 'undefined') {
    window.dataLayer = window.dataLayer || [];
    window.gtag = function gtag(): void {
        window.dataLayer.push(arguments);
    };
    window.gtag('js', new Date());
    window.gtag('config', site_google_tracking_id);
    if (log_lvl) {
        console.log(`AE Analytics: Google Analytics Tracking ID = `, site_google_tracking_id);
    }
}
</script>

<svelte:head>
<script
    async
    src="https://www.googletagmanager.com/gtag/js?id={site_google_tracking_id}">
</script>
</svelte:head>
