30

I like to add google analytics on my github respository. So i can keep track of user visit.

Prashant
  • 301
  • 1
  • 3
  • 4
  • 2
    You cannot. However, they do have their own [traffic analytics](https://github.com/blog/1672-introducing-github-traffic-analytics). – vcsjones Oct 19 '16 at 19:46
  • I tried this this way. It worked for me. On README.md files add this code snippet. [![Analytics](https://ga-beacon.appspot.com//chromeskel_a/readme?pixel)](https://github.com/) You can check this may help you more - https://github.com/igrigorik/ga-beacon – Prashant Oct 20 '16 at 20:00

4 Answers4

16

Unfortunately, you cannot use Google Analytics to monitor your GitHub repository page because you simply do not own the page. GitHub offers their own traffic analytics platform.

I have not verified this myself, but you if you have a GitHub Pages site at <your GitHub username>.github.io (or a specific project page using GitHub Pages), you could add Google Analytics to that site. It won't necessarily capture visits to the specific repository page, but it could help, especially if you have a particularly active GitHub Pages website.

See this related post for more info: How to add Google Analytics Tracking ID to GitHub Pages

Community
  • 1
  • 1
robbawebba
  • 349
  • 1
  • 7
  • 1
    Confirming (since this answer states the user did not verify) that you can add Analytics to a GitHub Pages instance. Even better to do so through Google Tag Manager so you don't need to constantly commit for tracking logic changes. – Chrysus Dec 08 '19 at 17:41
9

With ga-beacon you should be able to do minimal Google Analytics tracking on your GH repo. You won't be able to track to the level of detail that GH's own analytics does, but you should at least be able to track visits to your main repo page, for instance.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
  • ga-beacon is down since last month – Tony Qu Oct 09 '21 at 00:48
  • As noted in their docs, the ga-beacon.appspot.com instance is a demo instance, good for prototyping and proof of concepts. If you intend to use this in production for your application, you should deploy your own instance of this service. The following comment gives some helpful tips on setup: https://github.com/igrigorik/ga-beacon/issues/81#issuecomment-1127930027 – sfgeorge Jan 11 '23 at 15:48
5

I made a web app to record repo traffic, stars and other analytics data of github repos.

enter image description here

timqian
  • 3,106
  • 1
  • 14
  • 11
4

The Segment tracking pixel works great for this. Just embed that in your README/other files and you can record anonymous page hits to your repo.

osamakhn
  • 61
  • 4