add: gtm.

This commit is contained in:
Darshan
2025-09-09 08:38:47 +05:30
parent d79a2e9b87
commit aa6f1bfb00
2 changed files with 14 additions and 4 deletions
+9
View File
@@ -39,3 +39,12 @@ export function isMultiRegionSupported(url: URL): boolean {
return false;
}
}
// there can be multiple internal cloud instances.
export function isProductionCloud(url: URL): boolean {
try {
return url.hostname === 'cloud.appwrite.io';
} catch {
return false;
}
}
+5 -4
View File
@@ -6,7 +6,7 @@
import { trackPageView } from '$lib/actions/analytics';
import { Notifications, Progress } from '$lib/layout';
import { app, type AppStore } from '$lib/stores/app';
import { isCloud } from '$lib/system';
import { isCloud, isProductionCloud } from '$lib/system';
import { onMount } from 'svelte';
import { requestedMigration } from './store';
import { parseIfString } from '$lib/helpers/object';
@@ -174,9 +174,10 @@
<link rel="stylesheet" href={`${base}/fonts/cloud.css`} />
{/if}
<!-- Google Tag Manager -->
<script defer src={`${base}/scripts/gtm.js`}></script>
<!-- End Google Tag Manager -->
<!-- add GTM only on main instance -->
{#if isCloud && isProductionCloud(page.url)}
<script defer src={`${base}/scripts/gtm.js`}></script>
{/if}
</svelte:head>
<Root theme={resolveTheme($app.themeInUse)}>