How to add gtag google analytics to github pages
I have setup google analytics in the past. Somehow, with the new google analytics interface, I struggle with setting it up.
- There is a concept of an account (you will have one for “you”) and a property (one for your “site”)
- Access google analytics:
- Click admin
- Click create (this seems so obvious in retrospec, but I missed it several times) | property
- Follow prompts
- At end, grab the ID (G-123123123)
- Add to _config.yml for your github pages (typically in the root of your github repository):
Method 1:
google_analytics: G-123123123
Method 2:
# Analytics
analytics:
provider : google-gtag # false (default), "google", "google-universal", "google-gtag", "custom"
google:
tracking_id : G-B941W3153Q
anonymize_ip : # true, false (default)Note: for another template, I had to enter