DEV Community

Discussion on: Add Google Analytics through GTM (Google Tag Manager) on Next.js

Collapse
 
benbalderas profile image
Ben Balderas

I've tried this and it seems to work in next/head. I have a Layout component which has a Head, and this is used in every page. Placing the script in there should also work.

But I guess placing it in _document is best since this ensures the script is always on all pages.

Collapse
 
the_yamiteru profile image
Yamiteru

Yeah I did the same but forgot to add the general Page component to every page so I was missing the script in some of my pages.