Github Pages serves as an excellent platform for hosting your blog or website. Nevertheless, should you be interested in monitoring your site’s traffic and the behavior of your users, considering integrating Google Analytics might be a good idea. This article is dedicated to walking you through the steps of incorporating Google Analytics into Github Pages.
Step 1: Create a Google Analytics Account
The first step is to create a Google Analytics account if you don’t already have one. Go to Google Analytics and sign up for an account. Once you have created your account, you will be prompted to add a new property. Click on “Create Property” and enter the name of your website or blog.
Step 2: Add Google Analytics Code to Your Github Pages Site
The next step is to add the Google Analytics code to your Github Pages site. To do this, go to Google Analytics and select your property. Click on “Admin” in the left-hand menu and then select “Tracking Info” > “Tracking Code.” Copy the code that appears in the box.
Step 3: Add Google Analytics Code to Your Github Pages Site
Now, go to your Github Pages site and open the file where you want to add the Google Analytics code. In most cases, this will be the index.html
file. Add the following code just before the closing