r/learnprogramming • • 24d ago

How can I track GitHub repository visitors and file downloads in real time?

Hi everyone!
I've heard people mention things like "pinging a website" or "pinging a file" to track activity.
I'm wondering if there's a way to monitor how many people visit my GitHub repository and how many times a specific file gets downloaded.
Ideally, I'd like to see:
How many people visited my repository.

How many times a file was downloaded within the last 2 hours.

Whether I can monitor visitors or downloads in real time.

Is this possible with GitHub's built-in analytics, or would I need some external tools or services?
I'd appreciate any advice or examples of how to set this up. Thanks!

0 Upvotes

8 comments sorted by

1

u/kbielefe 24d ago

GitHub owns the server so your options are essentially limited to what they provide. If you want better metrics, you either need to put the download somewhere else (like an S3 bucket), or send people to GitHub via a link tracking service like bitly.

1

u/mandzeete 23d ago

Click on the "Insights" menu and then on "Traffic". It shows how many clones were done, how many visitors, referring sites, etc.

1

u/jjangg96 23d ago

small correction to the above, release assets do have per-file counts. the releases api returns an assets array and each asset has its own download_count, so you can see how many times each file was downloaded. it's a running total though, so for a 2 hour window you'd have to poll it and subtract.

the traffic numbers (views, clones, unique visitors, popular paths) are under Insights > Traffic or /repos/OWNER/REPO/traffic/views, but that's daily buckets for the last 14 days and you need push access.

a file that's just committed in the repo and grabbed through its raw url isn't counted anywhere. only release assets are.