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.

Question about Google Analytics code insert

See original GitHub issue

Hello!

Please, tell me. If I want to insert Google Analytics code to my site, then I should use Google Analytics Plugin, or create a custom component?

Why I can’t just insert Google Analytics code to header.js, or footer.js component? This is isn’t work? For example, on simple HTML-sites (Jekyll or Wordpress) I just insert Google Analytics code to before </body> close tag, and it’s enough.

Sorry for the noob question, I’m still learning Javascript + React…

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
marcysuttoncommented, Jan 30, 2020

The plugin is an abstraction to make working with Google Analytics easier to control from a gatsby-config without having to go deep into other files. But that makes sense why you’d want to have more fine-grained control over it: you could insert it yourself by creating an html.js file: https://www.gatsbyjs.org/docs/custom-html/

0reactions
LekoArtscommented, Feb 2, 2020

Thank you for opening this!

We’re marking this issue as answered and closing it for now but please feel free to comment here if you would like to continue this discussion. We also recommend heading over to our communities if you have questions that are not bug reports or feature requests. We hope we managed to help and thank you for using Gatsby!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Where to Put Google Analytics Tracking Code - Optimize Smart
Standard Google Analytics code should always be placed in the <head> tag of the page. Let's suppose you placed your analytics code at...
Read more >
Where is the Google Analytics Code & How to Track Your ...
Sign in to your Google Analytics account. · Click 'Admin.' · Next, click on the 'Tracking info' and from the drop-down menu. Select...
Read more >
How to Set Up Google Analytics: A Step-by-Step Guide
Enter in your website's name and click Add. Follow the directions to add the HTML code to your site. Once you're done with...
Read more >
Best place to insert the Google Analytics code - Stack Overflow
Show activity on this post. As google says: Paste it into your web page, just before the closing </head> tag. Worth mentioning that...
Read more >
How To Insert Google Analytics Code - Question - JoomShaper
I´m using google analytics and google tag manager. In fact of this I have to insert in the head-section of each site addtitional...
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