Performance issue with NextJs and Google Tag Manager

184 Views Asked by At

enter image description here

I am encountering an issue while integrating Google Tag Manager into my Next.js project. Is there a more efficient way to integrate Google Tag Manager? Because when I add it in the following way to _document.js:

enter image description here

my performance score automatically reduces in Lighthouse.

I have tried "beforeInteractive" "afterInteractive" "lazyOnload" at the end of the day they also reduce performance score in Lighthouse

1

There are 1 best solutions below

1
Feng Liu On

Use defer instead of async to your script tags