Google Analytics Glossary

Add Google Analytics to Github Pages

Image of Iron Brands

Published on Dec 23, 2022 and edited on May 12, 2023 by Iron Brands

Gathering insights into your website performance is vital for every business. Google Analytics has been the most popular analytics tool, with a market share of over 80%. It has been around for over 15 years and is the go-to tool for tech-savvy entrepreneurs and experienced marketing managers wanting to study their website visits.

To make your life easier, we’ve created this article to show you how to add Google Analytics to GitHub pages.

  1. How to add Google Analytics to Github Pages
  2. Google Analytics not showing data
  3. Google Analytics vs Simple Analytics
  4. Conclusion
Logo of MichelinMichelin chose Simple AnalyticsJoin them

How to add Google Analytics to Github Pages

Google Analytics is a popular web analytics tool that helps you understand your website's traffic and user engagement. It collects data on visitor demographics, traffic sources, and user behavior, displaying the information in organized reports. Google Analytics is a powerful tool for businesses and individuals alike, allowing you to make informed decisions about your website's content, marketing strategies, and overall performance.

To add Google Analytics to GitHub Pages, follow these steps:

Step 1: Create a Google Analytics Account First, create a Google Analytics account if you don't already have one. Visit the Google Analytics website and sign up using your Google account.

Step 2: Set up a new property Once logged in, create a new property for your GitHub Pages website. Name it, enter your website's URL, and choose an industry category and reporting time zone.

Step 3: Get your tracking ID and code After setting up your property, you will receive a tracking ID and a tracking code snippet. Keep these handy, as you will need them later.

Step 4: 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.

Step 5: 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 as described in Step 4.

Step 6: Commit and 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.

Google Analytics vs Simple Analytics

While Google Analytics offers many features and customization options, it can be overwhelming and complex for some users. Simple Analytics is an alternative web analytics tool focusing on simplicity and privacy. It does not use cookies and complies with data protection regulations like GDPR.

Simple Analytics provides essential web analytics data in a simple UI, making it a great option for those looking for a simpler, privacy-friendly alternative to Google Analytics. To integrate Simple Analytics with your GitHub Pages site, sign up for an account, get your tracking code, and follow similar steps as described in the Google Analytics integration above.

Conclusion

Adding Google Analytics with GitHub Pages can greatly benefit your website by providing valuable insights into user engagement and site performance. By following the step-by-step guide above, you can easily set up Google Analytics for your GitHub Pages site. If you're looking for a simpler, privacy-focused alternative, consider using Simple Analytics. We believe in an independent internet that is friendly to website visitors. If this resonates with you, feel free to give us a spin.

GA4 is complex. Try Simple Analytics

GA4 is like sitting in an airplane cockpit without a pilot license

Start 14-day trial