How to add Google Analytics to GitHub projects.
How to add Google Analytics to GitHub projects.

As I mentioned in a previous post we are prepairing to migrate our Bazaar repositories to Git, or more precisely to GitHub. This migration also heralds the Open Source releases of many of the core technologies we’ve been developing at Flight Data Services for the last few years.

I want to track visits for our GitHub projects. A bit of Googling turned up githalytics which enables you to track visits and page views for your GitHub projects using [http://www.google.com/analytics/](Google Analytics).

To use it, create a new Google Analytics property ID for your GitHub project, head over to http://githalytics.com/ and complete the web form. You’ll be provided a Markdown snippet to insert in your projects README.md. It will look something like this:

[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f "githalytics.com")](http://githalytics.com/YourGitHubName/YourGitHubProject)

Add the snippet to README.md and push the changes. When someone visits your GitHub project page, the visit will be tracked. Great!

However, we write all our documentation using reStructuredText. But after a quick Twitter and email exchange with Dimitrios from githalytics and I had a reStructuredText snippet. It looks something like this:

image:: https://cruel-carlota.pagodabox.com/0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f
    :alt: githalytics.com
    :target: http://githalytics.com/YourGitHubName/YourGitHubProject

Same drill, except add this snippet to README.rst and push the changes.

So there you have it, Google Analytics tracking of your GitHub project landing page. If you have more than one project, create a Google Analytics property ID and githalytics tracking snippet for each project.

References