Analytics script

Hi there,

I’m trying to add an analytics script to my Gatsby/ Netlify CMS project, so I’ve got a script tag that I’d like to paste into the of index.html. This should be really straightforward, but the problem is that index.html is in /public which is included it .gitignore, so it won’t be pushed if I make any commits.

Obviously I can remove it from .gitignore, but it seems like it was added there for a reason so I want to make sure I’m not breaking some sort of flow that I don’t understand.

Can I really solve my problem as easily as removing public/ from .gitignore and adding my script to public/index.html or is that going to break something in Gatsby/ Netlify CMS?

If you’re hosting your site on Netlify, why not use snippet injection:

1 Like

Seems like a roundabout way to do it, but it works, thanks!

1 Like