Tracking Visitors on a GitHub Blog with Google Analytics (GA4)
This post explains how to apply Google Analytics (GA4) to a GitHub blog and track visitor statistics.
[01] What is Google Analytics?
A Web Analytics Service from Google that tracks and reports website traffic.
It lets you monitor visitor statistics for your blog.
[02] Setting Up Google Analytics
Sign Up and Create an Account
-
Visit the Google Analytics site to create an account and walk through setup.

-
The account name does not need to match your Google ID.

- Use the blog URL as the property name.
-
Set the reporting time zone and currency to your locale (e.g., Republic of Korea / KRW).

-
Business information is optional (you can change it later).

-
Accept the Terms of Service.

- Accepting the terms completes the initial setup.
- To actually monitor traffic data, you need to configure a Data Stream and create a Measurement ID.
- The Measurement ID is added to the GitHub Blog config file so Google Analytics can track the page.
- Google Analytics currently runs as GA4 (Google Analytics 4) and uses IDs in the
G-XXXformat. -
The previous version, UA (Google Analytics 3), used IDs in the
UA-XXXformat.When you search for how to set up Google Analytics, you’ll see many posts referencing the UA-XXX tracking ID. Since we created a Google Analytics 4 property above, methods built around UA-XXX won’t work correctly.
-
A GitHub Blog is a web property, so select Web as the platform.

-
Enter the blog URL as the Website URL; choose any Stream name you like.

- Apply the Measurement ID (
G-4DKPW49KWZin the screenshot below) to the GitHub Blog.
GitHub Blog Configuration
Minimal Mistakes theme.
-
In
_config.yml, setprovidertogoogle-gtagand add themeasurement_id(create the field if it doesn’t exist) using the tracking ID above.
-
Add the following line inside the
<script>block in_includes/analytics-providers/google-gtag.html:1
gtag('config', );
[03] Verifying the Result
-
If everything is wired up, refresh the blog and check the Google Analytics home — the stats appear immediately.
