diff --git a/frontend/apps/web/app/BaseLayout.tsx b/frontend/apps/web/app/BaseLayout.tsx index 923db1e9d7..abd48501ac 100644 --- a/frontend/apps/web/app/BaseLayout.tsx +++ b/frontend/apps/web/app/BaseLayout.tsx @@ -5,7 +5,6 @@ import ConnectProvider from '@/components/providers/connect-provider'; import { PostHogIdentifier } from '@/components/providers/posthog-provider'; import TanstackQueryProvider from '@/components/providers/query-provider'; import { SessionProvider } from '@/components/providers/session-provider'; -import { UnifyIdentifier } from '@/components/providers/unify-provider'; import SiteHeader from '@/components/site-header/SiteHeader'; import { Toaster } from '@/components/ui/sonner'; import { ReactElement, ReactNode, Suspense } from 'react'; @@ -28,9 +27,6 @@ export default async function BaseLayout(props: Props): Promise { - - -
diff --git a/frontend/apps/web/app/api/config/config.ts b/frontend/apps/web/app/api/config/config.ts index fcf5536ae2..c9e544ab1c 100644 --- a/frontend/apps/web/app/api/config/config.ts +++ b/frontend/apps/web/app/api/config/config.ts @@ -35,6 +35,11 @@ export function getSystemAppConfig(): SystemAppConfig { publicNeosyncApiBaseUrl: PUBLIC_PATHNAME, // ensures that this always points to the same domain isJobHooksEnabled: process.env.JOBHOOKS_ENABLED === 'true', isRbacEnabled: isNeosyncCloud || process.env.RBAC_ENABLED === 'true', + gtag: { + enabled: isAnalyticsEnabled() && !!process.env.GTAG, + key: process.env.GTAG, + conversion: process.env.GTAG_CONVERSION, + }, }; } diff --git a/frontend/apps/web/app/config/app-config.ts b/frontend/apps/web/app/config/app-config.ts index 06601c80a9..be1abc3054 100644 --- a/frontend/apps/web/app/config/app-config.ts +++ b/frontend/apps/web/app/config/app-config.ts @@ -9,6 +9,7 @@ export interface SystemAppConfig { signInProviderId?: string; isMetricsServiceEnabled: boolean; isJobHooksEnabled: boolean; + gtag: GtagConfig; calendlyUpgradeLink: string; isGcpCloudStorageConnectionsEnabled: boolean; @@ -29,3 +30,9 @@ interface UnifyConfig { enabled: boolean; key?: string; } + +interface GtagConfig { + enabled: boolean; + key?: string; + conversion?: string; +} diff --git a/frontend/apps/web/app/layout.tsx b/frontend/apps/web/app/layout.tsx index 6bd1f9b1a2..fff7878860 100644 --- a/frontend/apps/web/app/layout.tsx +++ b/frontend/apps/web/app/layout.tsx @@ -1,4 +1,5 @@ import '@/app/globals.css'; +import { GoogleScriptProvider } from '@/components/providers/googleTag-provider'; import { PHProvider, PostHogPageview, @@ -36,6 +37,7 @@ export default async function RootLayout({ <> + diff --git a/frontend/apps/web/components/providers/googleTag-provider.tsx b/frontend/apps/web/components/providers/googleTag-provider.tsx new file mode 100644 index 0000000000..9ead37b674 --- /dev/null +++ b/frontend/apps/web/components/providers/googleTag-provider.tsx @@ -0,0 +1,47 @@ +'use client'; +import { useGetSystemAppConfig } from '@/libs/hooks/useGetSystemAppConfig'; +import Script from 'next/script'; +import { ReactElement } from 'react'; + +export function GoogleScriptProvider(): ReactElement { + const { data: systemAppConfig, isLoading } = useGetSystemAppConfig(); + + if ( + isLoading || + !systemAppConfig?.gtag.enabled || + !systemAppConfig.gtag.key + ) { + return <>; + } + return ( + <> +