Horje
How To Add Google Analytics To GitHub Pages?

GitHub website is a great way to host websites from your GitHub repository, perfect for showing off projects or personal websites. But, it doesn’t come with integrated tools to see how many users come to see your site or what they do there. To get these details, you can apply for Google Analytics.

This guide will describe how to connect Google Analytics to your GitHub Pages so you can trace your visitors and understand their behaviour.

Steps to Add Google Analytics To GitHub Pages

Step 1. Create a Google Analytics Account

imresizer-1720829106527

Create Google Analytics Account

Step 2. Fill this section

imresizer-1720829131506

Create Google Analytics Account


Step 3. Check the option boxes

imresizer-1720829152193

Create Google Analytics Account


Step 4. Fill this section as your Name or time zone

imresizer-1720829199112

Create Google Analytics Account

Step 5. Accept the terms and condition

imresizer-1720829251951

Create Google Analytics Account

Step 6. Select your company size

imresizer-1720829217174

Create Google Analytics Account


Step 7. Select the box which you want to choose

imresizer-1720829234978

Create Google Analytics Account

Step 8. Accept the Terms and Condition

imresizer-1720829251951

Create Google Analytics Account

Step 9. Now you see the following window click Web options.

imresizer-1720829272862

How To Add Google Analytics To GitHub Pages?

Step 10. Click the Create and Continue Button

imresizer-1720829295565

How To Add Google Analytics To GitHub Pages?

Step 11. Now you successfully connect your Github to Google Analytics

imresizer-1720829318539

How To Add Google Analytics To GitHub Pages?

Now you see my Github Analytics graph.

imresizer-1720829333692

How To Add Google Analytics To GitHub Pages?

Pseudocode

<!-- Google Analytics -->
<script async src=
"https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX">
</script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>
<!-- End Google Analytics -->


imresizer-1720863064495

How To Add Google Analytics To GitHub Pages?

JavaScript
<!-- Google Analytics -->
<script async src=
      "https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX">
</script>
<script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){   dataLayer.push(arguments);   }
    gtag('js', new Date());

    gtag('config', 'G-XXXXXXXXXX');
</script>

Replace ‘G-XXXXXXXXXX’ with your actual Measurement ID

Step12. Here is your mesurement id just copy and replace in code

imresizer-1720827802278

How To Add Google Analytics To GitHub Pages?


Step13. Open Your Github account make a repositary

imresizer-1720863638054

How To Add Google Analytics To GitHub Pages?

Click To Commit Changes

imresizer-1720863662321

How To Add Google Analytics To GitHub Pages?

Here you see your Github traffic graph

imresizer-1720829333692

How To Add Google Analytics To GitHub Pages?




Reffered: https://www.geeksforgeeks.org


Git

Related
How To Add Line Break To &#039;git commit -m&#039; From The Command Line? How To Add Line Break To &#039;git commit -m&#039; From The Command Line?
How To Get The Git Commit Count? How To Get The Git Commit Count?
Effective Methods for Visualizing Branch Topology in Git Effective Methods for Visualizing Branch Topology in Git
How to Use Git Shell Commands? How to Use Git Shell Commands?
Getting Git To Work With a Proxy Server Getting Git To Work With a Proxy Server

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
22