window.gtag is not defined for Next.js-hydration event #40410
Labels
examples
Issue was opened via the examples template.
good first issue
Easy to fix issues, good for newcomers
Verify canary release
Provide environment information
Which example does this report relate to?
with-google-analytics
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
calling
reportWebVitals
when having google analytics setup usingwith-google-analytics
results inNext.js-hydration
event getting triggered BEFORE gtag is initialized.This could be problematic in production if someone is just assuming
gtag
is always defined when reporting on web vitals.Expected Behavior
When having google analytics setup using the
with-google-analytics
example, I would expectgtag
to be defined for all events before triggeringreportWebVitals
.To Reproduce
Here is a link to reproduce: https://stackblitz.com/edit/nextjs-rnaue8?file=pages%2F_app.js,.env.local.example,lib%2Fgtag.js,pages%2Findex.js
The text was updated successfully, but these errors were encountered: