Google is advising to put all of the gTag code inside the <head> .
See original GitHub issueGoogle is advising to put all the gtag
code inside the <head> element.
Why can’t I find nothing about this advice in any of the docs of Next, when using Next/Script?
Also, now the Google Analytics implementation is not working, it only works when gtag script is inside <head> element.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Should You Place The GA Tracking Code In The Header or ...
This is the main reason why Google recommends putting your tracking code in the header, but by making the GA tracking code asynchronous,...
Read more >Should I put the Google Analytics JS in the <head> or at the ...
Putting it at the end of the <head> section helps ensure the your metrics are tracked even when a user doesn't let the...
Read more >Google Tag Manager Container Code. In head or body?
Where should you place your Google Tag Manager container code? Website head or body? This blog post will explain.
Read more >Set up and install Tag Manager - Google Support
Google Tag Manager lets you configure and deploy tags from Google products ... Place the <script> code snippet in the <head> of your...
Read more >Where Should The Google Tag Manager Snippet Be Placed?
Google Tag Manager recently changed their implementation guidelines and now recommends two snippets, one in the Head and one in the Body.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can read more about how to load analytics scripts in our docs under
next/script
:https://nextjs.org/docs/basic-features/script#afterinteractive
Next.js will inject the script into
head
for you, and add necessary optimizations to defer loading the analytics script after the page has become interactive to ensure performance.This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.