diff --git a/app/layout.tsx b/app/layout.tsx index 6d9feae3..68b6d6c0 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,4 +1,5 @@ import { Metadata } from 'next'; +import GoogleTagManagerScript from '../components/head/GoogleTagManagerScript'; // Nextjs automatically includes for each route two default meta tags, charset and viewport // https://nextjs.org/docs/app/building-your-application/optimizing/metadata#default-fields @@ -15,7 +16,14 @@ export default function RootLayout({ }) { return ( - {children} + + {/* + We should be using next third party library https://nextjs.org/docs/app/building-your-application/optimizing/third-party-libraries#google-tag-manager + but sending an event using sendGTMEvent requires an object rather than a list of arguments so the current gtag api function would need to be adapted + */} + + {children} + ); } diff --git a/components/head/GoogleTagManagerScript.tsx b/components/head/GoogleTagManagerScript.tsx index 317d4937..47736c0c 100644 --- a/components/head/GoogleTagManagerScript.tsx +++ b/components/head/GoogleTagManagerScript.tsx @@ -4,7 +4,7 @@ const GoogleTagManagerScript = () => { return (