IO WEB PRO

Contact Ibrahim via WhatsApp
Contact Ibrahim via WhatsApp
Chat with Ibrahim on WhatApp now!

Straightforward Solution to Metadata Not Working After Google Analytics Integration on Next JS 13

July 14, 2023
Metadata Stopped Working After Google Analytics Integration on Next JS 13

Integrating Google Analytics on a Next.js 13 website can feel a little overwhelming. But fret not! We have two amazing resources to help you through this process, making it a breeze.

By following either of these resources, you will successfully integrate Google Analytics into your Next.js 13 website.

However ...

...there's a possibility that your metadata might encounter a bug and stop working correctly. But don't worry, we have a simple fix for that

read How To Get Maximum SEO Result From My Metadata.

The Fix

To fix your metadata issues, just wrap the Google Analytics component in your root layout using suspense like 👇🏾.

This is how you wrap the Google analytics component in a suspense to make your metadata work on nextjs 13

This small adjustment will prevent any conflicts and keep your metadata intact.

There's another potential error you might face, where 'window.tgag' is undefined. But here's the solution:

head over to your cookie component and wrap the 'window.gtag' part in the useEffect hook with a condition that skips the code when it is undefined like 👇🏾.

if you encouter a window.gtag not defined problem as well, fix it as shown in this image.

This quick fix will resolve the error and ensure a seamless Google Analytics integration.

so there you have it, the straightforward quick fix to metadata not showing up bug on next js 13 after google analytics integration.

Enjoy the rest of the day.



Hello! My name is Ibrahim and I am a seasoned web, mobile apps and AI developer open to collaborations and freelance.

...Or connect with me via