开发者

Add Google Analytics to Github wiki pages

I have a couple of Github projects that I want to be able to track the traffic to. I have done this in the past by adding Google Analytics tracking code to each wiki page. However, the Github wiki upgrade in September broke this and I don't seem to be able to add Javascript code to my wiki pages anymo开发者_如何学Gore.

A couple of random other points: 1) I'm aware that Github probably blocked JS on the wiki for security reasons. 2) I know Github provides its own very basic traffic graph but I would like all the power of GA.

Is there any way for me to restore Google Analytics tracking to my Github wiki? If not, is there an alternative?


You could leverage the Google Analytics for Mobile strategy.

The draw backs are that :

  • You would only be able to manually publish static image urls in for each wiki page.
  • You would need to host the Google Analytics for Mobile server-side file on another server. Somewhat negating the whole exercise.


Lately, the "Traffic" feature is unavailable. In order not to implement something of your own, I have created githalytics.com which let you "add" google analytics to your github repository. Of course there are limitations and drawbacks as mentioned before. Free free to check


Note that since January 2014, GitHub provides Traffic Analysis with a bit more information, for all pages of your repo (including commit activity, wiki, ...):

"Introducing GitHub Traffic Analytics"

Add Google Analytics to Github wiki pages


In 2019, Tim Qian mentions in the comments:

The only problem is it only stores traffics for 14 days.
To resolve it, I made a tool to record it: repo-analytics.github.io.


You can either use Github traffic analysis (see VonC answer) or ga-beacon, a project by Ilyah Gregorik.

  • Create a new web property in analytics
  • Bind it to https://ga-beacon.appspot.com/
  • Add this markup to your pages (replace UA-XXXXX-X, your-repo and page-name):

    [![Analytics](https://ga-beacon.appspot.com/UA-XXXXX-X/your-repo/page-name)](https://github.com/igrigorik/ga-beacon)

This will display a badge in your wiki page, but you can also use a single-pixel image.


The other alternative is to include an external image on each of your wiki pages. Then, track the image download stats.

You could then host the images on an image hosting provider that allows:

  1. Download stats
  2. SSL Support - If you link to an external image that
  3. Hotlinking

I'm still searching for such a image hosting provider which provides all of this. I will post back once I find a suitable one.

i posted my research here: https://stackoverflow.com/questions/12795081/i-want-to-track-page-views-on-my-github-wiki-pages-any-suggestions-for-an-ima?lq=1


As an alternative to ghalytics.com, I also came across BitDeli Github Badge: https://github.com/bitdeli/profile-ghbadge

It's pretty much the same thing, except it uses BitDeli as the analytics engine instead of GA.

Both suffer from the same apparent limitation: they can not capture the referrer header, since you need JS to extract that. This means that you cannot do analysis on search keywords, sites that link to you, or social network sources. Which is one of the main uses of GA, in my opinion.

The only workaround I can think of is to create a different landing page for your repo than README.md, and then hope that all your traffic will come through the landing page instead of directly to your repo. This landing page could just be a URL shortener (eg bit.ly) with its own analytics service, or a github-pages site with a GA snippet.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜