21

Is it possible to track and view/analyze traffic to a GitHub repository (possibly with referrers information) for a period longer than 14 days? That seems to be the longest period that I can see via GitHub "Traffic" graph.

From another answer, suggesting to use badges and some third party service, I navigated to a blogpost, claiming that Github now caches images from READMEs, and thus this solution won't work either, reportedly.

2
  • Sounds like a simple fix with a little IFTTT ifttt.com/recipes?channel=github&page=1 May 21, 2014 at 21:41
  • @designerWhoCodes: would you care to elaborate? at the link you provided, I see some 200 "github recipes", but after reading through the first few pages I can't seem to find one to mention anything like "traffic" or "visitors"?
    – akavel
    May 23, 2014 at 10:55

9 Answers 9

7

Not possible as of 2015-05-19

I wrote this message https://github.com/isaacs/github/issues/399 to https://github.com/contact and Ivan Žužak replied by email:

Not possible currently, but thanks for your +1 -- I'll pass it along to the team.

confirming it is not currently possible.

A better approch might be to enable Google analytics on GitHub as proposed at: https://github.com/isaacs/github/issues/446

3
  • 1
    OK, well that was a long time ago .... why is this not a thing yet? I mean seriously, it can't be that hard to allow manipulation of what should be a single variable to get more time in view
    – SpYk3HH
    Apr 20, 2016 at 14:33
  • 1
    I do not want to take too much credit, but people seem to really like github.com/jgehrcke/github-repo-stats. It's an all-in-GitHub solution (no external service required). I have described it in an answer further below: webapps.stackexchange.com/a/160642/287085. Dec 8, 2021 at 13:40
  • @Dr.Jan-PhilipGehrcke thanks for the info, that's an interesting GH Action. Didn't know they had cron capability. Dec 8, 2021 at 13:47
6

This can be done using the GitHub REST API.

Two projects using this are github-traffic-stats (exports to csv) and GitHubTelemetryParsor (SQL MS Visual Studio project).

2
  • Is this question or answer?
    – serenesat
    Feb 24, 2017 at 18:20
  • 1
    an answer: by pulling the stats regularly with the stated github-projects you can collect it regularly (e.g. via crontab) and therefore have a history longer than 14days
    – hirsch
    Feb 25, 2017 at 18:40
2

I made a web app to record repo traffic, clones, referrers and other analytics data. Welcome to try it out

enter image description here

1
  • Error 502 Bad gateway when I try to login. Sep 21, 2021 at 23:32
1

Tracking pixels can do the trick, but you cannot filter out spam requests and cannot count unique visitors count. The only way - daily download and aggregate repository traffic data. It's not that hard, but have some edge cases.

I've made a public service Ÿ HŸPE which could do that job for you. It aggregates repository traffic, clones, referrers & stars, user profile views & followages.

Y HYPE GitHub Traffic Page

1

I have built https://github.com/jgehrcke/github-repo-stats. Every day, it generates a nice HTML and PDF report and from my point of view the most important part is that the data stays in GitHub. You don't need a cloud service to integrate this with. No S3 or so.

This is an all-in-GitHub solution, triggered to act periodically (once per day) via GitHub actions.

The time series data is simply stored in a "data repository" (where you run this action in), with transparent evolution of history.

The HTML report can be exposed via GitHub Pages. A demo is linked in the README of https://github.com/jgehrcke/github-repo-stats.

An example screenshot:

enter image description here

0

Here's also an automated solution that uses Azure LogicApps to pull the data from the GitHub API and store it in table storage.

https://github.com/matthansen0/logicapp-githubstats

0

I wrote a couple of bash scripts that use GitHub traffic API. One very simple shell script uses crontab to schedule the download of GitHub traffic statistics in plain text from your GitHub repositories. Another shell script prints the text lines to add to crontab and sets up the directories for GitHub traffic statistics. It takes minutes to setup but weeks to get enough data. At this point you can process the data with any tools you wish. I created a third script that parses the GitHub traffic and creates two markdown tables (clone, views).

It solves my challenge. It may help you.

https://github.com/BradleyA/Linux-admin/tree/master/github-repository-traffic#github-repository-traffic

0

Answered here:

https://stackoverflow.com/questions/4338358/github-can-i-see-the-number-of-downloads-for-a-repo/70047423#70047423


Port into GitHub composite action to reuse workflow code base.

https://github.com/andry81-devops/github-accum-stats

With additional features:

  1. Can count traffic clones or/and views.
  2. Can use GitHub composite action to reuse workflow code base: https://docs.github.com/en/actions/creating-actions/creating-a-composite-action

GitHub workflow file example:

.github/workflows/accum-gh-clone-stats.yml

0
0

Happy to see lots of unique solutions out here. Adding one more. My solution uses Google Apps Script with Google Sheet to automate this stuff. You can track as many repos as you want in a single document using multiple sheets. Also generates a good looking graph for each Repo.

Code Url: https://gist.github.com/Nirav-Madhani/daee9a3b5173b786be85049a984fb927

Full Tutorial: https://nirav-madhani.netlify.app/post/github-stats-tracking/

Sample

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.