diff --git a/apps/web/src/app/api/marketing-tags/gtm/route.ts b/apps/web/src/app/api/marketing-tags/gtm/route.ts new file mode 100644 index 000000000..906d5697b --- /dev/null +++ b/apps/web/src/app/api/marketing-tags/gtm/route.ts @@ -0,0 +1,15 @@ +import { NextResponse } from 'next/server'; +import { buildGoogleTagManagerScript } from '@/lib/marketing-tag-scripts'; + +export function GET() { + if (!process.env.NEXT_PUBLIC_GTM_ID) { + return new NextResponse(null, { status: 404 }); + } + + return new NextResponse(buildGoogleTagManagerScript(process.env.NEXT_PUBLIC_GTM_ID), { + headers: { + 'Content-Type': 'application/javascript; charset=utf-8', + 'Cache-Control': 'public, max-age=300, s-maxage=300', + }, + }); +} diff --git a/apps/web/src/app/api/marketing-tags/impact/route.ts b/apps/web/src/app/api/marketing-tags/impact/route.ts new file mode 100644 index 000000000..42588a198 --- /dev/null +++ b/apps/web/src/app/api/marketing-tags/impact/route.ts @@ -0,0 +1,15 @@ +import { NextResponse } from 'next/server'; +import { buildImpactUttScript } from '@/lib/marketing-tag-scripts'; + +export function GET() { + if (!process.env.NEXT_PUBLIC_IMPACT_UTT_ID) { + return new NextResponse(null, { status: 404 }); + } + + return new NextResponse(buildImpactUttScript(process.env.NEXT_PUBLIC_IMPACT_UTT_ID), { + headers: { + 'Content-Type': 'application/javascript; charset=utf-8', + 'Cache-Control': 'public, max-age=300, s-maxage=300', + }, + }); +} diff --git a/apps/web/src/app/layout.tsx b/apps/web/src/app/layout.tsx index 6ec855881..b68d1e9ab 100644 --- a/apps/web/src/app/layout.tsx +++ b/apps/web/src/app/layout.tsx @@ -5,7 +5,6 @@ import './globals.css'; import { PostHogProvider } from '../components/PostHogProvider'; import { Providers } from '../components/Providers'; import { DataLayerProvider } from '../components/DataLayerProvider'; -import { GoogleTagManager } from '@next/third-parties/google'; import { APP_URL } from '@/lib/constants'; const inter = Inter({ @@ -113,13 +112,15 @@ export default function RootLayout({ {process.env.NEXT_PUBLIC_GTM_ID && ( - + + '); + + expect(script).toContain('GTM-TEST\\u003C\\u002Fscript\\u003E'); + expect(script).not.toContain(''); + expect(script).not.toContain(''); + + expect(script).toContain('https:\\u002F\\u002Futt.impactcdn.com\\u002Fimpact'); + expect(script).toContain('\\u003C\\u002Fscript\\u003E'); + expect(script).not.toContain(''); + expect(script).not.toContain('