Reputation: 53
I have my website hosted on github pages and I wanted to add Google Analytics to count views on it. I created a Google Analytics account, created a new UA property and added full path to my website ( username.github.io/reponame/ ). Then I added global site tag to head of my index.html ...
I waited for some time but still I can see 0 active viewers in analytics page even if I active on my website using 2 devices...
Since I found various answers about setting up analytics with Jekyll, I added Cayman theme, edited _config.yml, added _includes and did whatever said in that blog but still it didn't work ( I am not used to github actually )... So, I removed whatever changes I made for that Jekyll thing and now my repository consists of only stuff which I added in the beginning.
Why is it not working on my website ? Did I go wrong somewhere ?
How do I add Google Analytics if my repository currently consists of only index.html, css files and JS files ?
Upvotes: 2
Views: 1587
Reputation: 2937
Make sure to have included {% include analytics.html %}
in your website somewhere. The best practice is to put it into the head of your HTML.
Inspect your webpage, for instance with Chrome tools, to check that the script containing your Analytics ID is indeed loaded. You should see something like:
<script async src="https://www.googletagmanager.com/gtag/js?id=G-ZKGE3RWEMU"></script>
Upvotes: 0