question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

gatsby-plugin-google-analytics sets tracking code in the body

See original GitHub issue

The google analytics plugin sets the tracking code in the <body /> here.

Any reasons for this? I’d like to move it to <head /> because Google Webmasters tools requires that “tracking code should be in the <head /> section of your page,” when verifying the property.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
cmwallcommented, Mar 20, 2018

Even with the merged PR (https://github.com/gatsbyjs/gatsby/pull/3995), the script is still being added to the end of the body for me.

The head component never gets the script.

{
  resolve: `gatsby-plugin-google-analytics`,
  options: {
    trackingId: "id",
    head: true,
  },
}

Any ideas on what I’m doing wrong here?

2reactions
crgearycommented, Jan 26, 2018

Sweet… Just been speaking to @endymion1818 and he wants to take a shot at implementing this 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

gatsby-plugin-google-analytics
This plugin uses Google's analytics.js file under the hood. ... options: { // The property ID; the tracking code won't be generated without...
Read more >
How to add Google analytics in Gatsby - Mario Kandut
Install the official Google analytics plugin gatsby-plugin-google-gtag OR; Add the tracking code to customized html.js.
Read more >
Gatsby and Google Analytics - Aman Kumar
Put gatsby-plugin-google-analytics in your gatsby plugins. ... By setting it to false, it will be placed in the <body>. ... Check the tracking...
Read more >
How to Add multiple Tracking ID for Google Analytics in ...
I already have one tracking code in my gatsby.config.js file like so { resolve: "gatsby-plugin-google-analytics", options: { trackingId: "UA- ...
Read more >
Gatsby Google Analytics 4.0 | Step-by-Step Guide Using Gtag ...
1. Create a Google Analytics 4.0 account and property · 2. Generate a measurement ID · 3. Install Gatsby Google Analytics plugin Gtag...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found