Google Analytics Glossary

Add Google Analytics to Github Pages

Image of Iron Brands

Published on Dec 23, 2022 and edited on May 7, 2024 by Iron Brands

Gathering insights into your website performance is vital for every business and Google Analytics can help with that. To make your life easier, we’ve created this article to show you how to add Google Analytics to GitHub pages step by step.

Let's dive in!

  1. Step-by-step integration
    1. Set up a Google Analytics property
    2. Add the tracking code to your website
    3. Include the analytics in your site's layout
    4. Push your changes
  2. Google Analytics not showing data
  3. Final Thoughts

Before we dig in you need to know that Google Analytics is complex and a bit clunky. There are other options that give you the same insights in a slick and straightforward dashboard.

Simple Analytics is one of them. A privacy-friendly and simple analytics tool - just the insights you need in a straightforward dashboard. (And its also free yes).

Can you spot the difference between the dashboards?

All right, now let's get into answering your question!

Step-by-step integration

Set up a Google Analytics property

  • Log into your GA account (or create one, if you haven't already).
  • Create a GA property for your website.
  • Inspect your property and note its Measurement ID. You will need this ID later.

Add the tracking code to your website

For a Jekyll-based GitHub Pages site, create a new file called _includes/analytics.html and paste your Google Analytics tracking code snippet into this file. If your site is not built with Jekyll, simply add the tracking code snippet to the head section of every HTML file on your site.

Include the analytics in your site's layout

For Jekyll-based sites, add {% include analytics.html %} to your site's default layout file (_layouts/default.html) just before the closing head tag. This will include your Google Analytics tracking code on every page of your site. For non-Jekyll sites, ensure that the tracking code is added to each HTML file.

Push your changes

Commit and push your changes to your GitHub Pages repository. Google Analytics will start tracking user activity on your website within 24 hours.

Google Analytics not showing data

If Google Analytics is not showing any visitor data, try the following troubleshooting steps:

  • Verify that your tracking code is installed correctly and appears on all pages.
  • Check that your tracking ID matches the property ID in your Google Analytics account.
  • Ensure that your website is accessible and not experiencing downtime.
  • Double-check that you do not have any filters or settings in Google Analytics that block specific traffic sources or user data.
  • Give it some time. It may take a few hours or up to 24 hours for Google Analytics to start displaying data.

Final Thoughts

Adding Google Analytics to your website can give you great insights. However, ask yourself: is Google Analytics the right tool for you?

GA is an overpowered solution for straightforward analytics. If you're looking for a simple and intuitive dashboard with the insights you need, there are better alternatives.

If this resonates with you, feel free to give Simple Analytics a spin. You just need to add the script to your app and off you go. This takes about one minute- and there is a free version as well!