Setup Google Analytics on your Jekyll Static Web Site
I recently setup Google Analytics to track activity on my Jekyll generated website that I host on Azure Blob Storage.
The first thing you have to do is go and sign up for Google Analytics.
Once you’re in you need to create a new property. so start by opening the menu navigation and clicking at the bottom and selecting “Admin”.
Then click the “Create” drop down and select “Property”. During the signup process you already created an Organization. Think of a “Property” as a “web property” or a web site. I suppose it could also be a mobile app as well.
Give the property a name. I name my properties after their primary domain name. In this case I’m setting up a new web site for my youtube channel and Terraform community called Azure Terraformer so I’ll name it “AzureTerraformer.com”.
Given this is a passion project of mine and not a real company by any stretch of the imagination. The answers here are pretty obvious.
I think the selections here manifest in some sane defaults in later configurations. Given this is essentially a marketing web site and blog I opted for “Traffic” and “User engagement”.
Now that we are done just select “Web” and it’ll generate you some HTML you can embed on your site.
You need to fill out a few more pieces of data. These of course just need to be the domain name of the web site.
Like I did for the property I setup a stream name by the same name as the domain. So both answers are “AzureTerraformer.com”. Because I haven’t setup HTTPS yet, I select HTTP://
.
This is the HTML you can drop on your web site if you had a normal HTML based web site but of course with Jekyll we are generating the HTML from markdown files. So it’s gonna be a little different for us.
Now this definitely depends on the template you are using. If you have built your own custom template then you very likely could just drop this HTML into that. I happen to be using a Jekyll template that has an extension for Google Analytics. Therefore I just need to figure out what the configuration settings are and update the _config.yml
file.
# Google analytics - GA4
google_analytics: G-XXXXXXXXXX
enableDNT: "false"
Replacing the X’s with the actual value you saw in the Google tag that was generated once you completed the setup on Google Analytics. That’s it! Now get ready for an awesome command center to watch your traffic flow in!!!