DEV Community

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

Collapse
 
mog profile image
Morgan Feeney

Every time I have delved into this issue, it turned out that pageProps fires after the router events, so this implementation (even though its recommended by Next.js examples) only does one job: tracking a page view.

If you want to start pushing data into the dataLayer via pageProps it is limited.

I wrote about this here: morganfeeney.com/how-to/integrate-..., you're welcome.