This is an unofficial Google Analytics for GitHub repositories tracking using Azure Functions and written in Node.js. You can use this to track pageviews in all pages that contain Markdown, like READMEs, wikis etc.
GitHub has a mechanism by which you can see tracking information about your repositories, you can read about it here. However, it hosts data only for the last 14 days and there is no real time information.
GitHub uses camo to cache and serve images (details), so (a) tracking may not be accurate and (b) user details are hidden (IP, referer, etc.).
- Click here to visit Google Analytics and create a new account
- When you are done, copy your Tracking ID (should be in the format UA-XXXX-Y)
- Click the button below to deploy the project in your Azure subscription
- When the deployment is completed, copy your Functions URL (should be something like
https://yourfunctionname.azurewebsites.net
) - Edit your README files in your repos that you want to track (or any files that contain markdown) and insert the necessary code.
First, change YYYYYY
to your Azure Function's URL. Then, change XXXXXXXX
to a distinctive name to use in order to track this specific page. Might be the name of your repo or whatever you like. If you want to display a button use this code:
[![unofficial Google Analytics for GitHub](https://YYYYYY.azurewebsites.net/api?repo=XXXXXXXX)](https://github.com/dgkanatsios/gaforgithub)
If you do not want to display the button, use this code:
![](https://YYYYYY.azurewebsites.net/api?repo=XXXXXXXX&empty)
The deployment uses Azure Functions' Consumption Plan so you'll see that it's really cheap to host it for your projects.
Inspired by igrorik's solution here that works with Go language and Google App Engine.