portfolio-starter
portfolio-starter copied to clipboard
How would I add analytics?
How could I add google analytics to my site?
Follow Google's basic instructions. For step 3 ("…add the tag right after the opening <head>
tag on each page"), you'll want to add the code to the base layout file, which gets used for all site pages:
/_includes/layouts/base.njk
Let me know if any issues!
If using Netlify for hosting then you can use their analytics add-on. It isn't free ($9/mo) but it's a good option, particularly since there's no code needed to set it up.
another (free) option if using Netlify is to take advantage of their snippet injection. in fact, the documentation mentions analytics as a use case
Most analytics providers, retargeting services, and A/B testing services will give you an HTML snippet and ask you to add it to every page on your site. Netlify lets you do this without having to pollute the source code for the site with production specific analytics snippets.
Very useful to know, thanks @zackseuberling!