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 PagesStep 1. Create a Google Analytics Account
 Create Google Analytics Account Step 2. Fill this section  Create Google Analytics Account Step 3. Check the option boxes
 Create Google Analytics Account Step 4. Fill this section as your Name or time zone
 Create Google Analytics Account Step 5. Accept the terms and condition  Create Google Analytics Account Step 6. Select your company size  Create Google Analytics Account Step 7. Select the box which you want to choose
 Create Google Analytics Account Step 8. Accept the Terms and Condition Create Google Analytics Account Step 9. Now you see the following window click Web options. How To Add Google Analytics To GitHub Pages? Step 10. Click the Create and Continue Button How To Add Google Analytics To GitHub Pages? Step 11. Now you successfully connect your Github to Google Analytics  How To Add Google Analytics To GitHub Pages? Now you see my Github Analytics graph. 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 -->
 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 How To Add Google Analytics To GitHub Pages? Step13. Open Your Github account make a repositary
 How To Add Google Analytics To GitHub Pages? Click To Commit Changes How To Add Google Analytics To GitHub Pages? Here you see your Github traffic graph How To Add Google Analytics To GitHub Pages?
|