I'm developing a Firefox extension and would like to track its use with google analytics, but I can't get it working.
I've tried manually calling a function from ga.js, but that didn't work for some reason. No error was produced, but neither was any data collected.
My last attempt was to have a website that just holds the tracking javascript and then load it within the extension in an iframe with the URL configured so it contains meaningful data. This way the analytics are getting connected when I visit said webpage with a browser, but not in an extension. I've tried putting some visible javascript on the site and have confirmed the site's javascript is executing. This method also works with other trackers, but I don't like their output and would prefer Google Analytics.
Any ideas what else I could try to accomplish this?
The solution is to use Remy Sharp's mini library for tracking bookmarklets and extensions with Google Analytics. Works like a charm.
Usage is as simple as:
gaTrack('UA-123456', 'yoursite.com', '/js/script.js');
Note that, since it doesn't use cookies, there's no differentiation between pageviews and visits, or for that matter, between visits and visitors. But, the rest of the functionality is fairly reliable.
Depending on what you want to track you may not need Google Analytics. Mozilla's addon.mozilla.org portal already provides comprehensive tracking and usage statistics for addons.
To check if Mozilla provides what you need go to the Statistics Dashboard and choose the statistics for one of the publicly available addons.
Here is a small library to proxy the requests through an iframe hosted on another server: https://github.com/yelloroadie/google_analytics_proxy
This gets around the bug in the add-on sdk that causes ga.js to die (https://bugzilla.mozilla.org/show_bug.cgi?id=785914).
This method allows full use of google analytics, unlike the limited use found in the library by Remy Sharp.
I don't think this is possible. Firefox extensions don't allow you to load pages from other servers. So the only way I can think of is to have an invisible iframe load up the code. The pings to Google's servers need to be from a domain belonging to you. So I guess your own servers have to serve up pages every time a user loads the extension, which just kills your server and defeats the purpose of Google doing all the work!! Please post if you have found a way around it. Chrome extensions can be tracked easily!
For using analytics in the main/background script you might want to use this solution:
https://stackoverflow.com/a/17430194/193017
Citing part of the answer:
I would suggest you take a look at the new Measurement Protocol in Universal Analytics:
https://developers.google.com/analytics/devguides/collection/protocol/v1/
This allows you to use XHR POST to simply send GA events directly.
This will coexist much better with Firefox extensions.
The code would look something like this:
Related
I've written some code that retrieves some data from google sheets then updates some content on my google sites. However, while the script works (when run on localhost) I encounter the
"details": "Not a valid origin for the client: https://966655698-atari-embeds.googleusercontent.com has not been whitelisted for client ID MY-ID. Please go to https://console.developers.google.com/ and whitelist this origin for your project's client ID."
However, I enabled this for localhost, cleared my caches. The problem is the 'https://966655698-atari-embeds'. Each time the google site loads it generates a new random number sequence. Does anyone know how to workaround this? The google site uses embedded html which I believe is why the initialization failed.
I have tried to white-list https://googleusercontent.com which didn't work (I didn't think it would because the domain changes) but I'm honestly incredibly stumped.
Google hosts all user content using their somedomain.googleusercontent.com. I do not know for certain, but I'm almost sure that to save space they dynamically host their content, meaning that when the embedded html does not need to be actively hosted, it isn't. I had to find a way to host from a site that would always send the request. For me, I found that github pages was the answer.
I found this on adobe's website which somewhat explains what googleusercontent does. https://helpx.adobe.com/analytics/kb/googleusercontentcom-instances.html
To set up github pages this link will explain how to do so https://guides.github.com/features/pages/
You can add this to the developer Google console relatively easily and any connection will submit from your username.github.io. (I believe it also uses https protocol). It also allows me to implement directly using git version control and implements nicely with WebStorm.
I'm trying to install some script on one of my websites to track outbound links and downloads in Google Analytics but I'm not having much luck. This is the script that I'm using (if anyone knows of a better guide or script I'd love to hear about it).
My question is this: How can I check whether it's working without using Google Analytics? Is there a way I can see the events or data that's being sent when a link or download is clicked using Firebug or Developer Tools?
Thanks in advance,
Tom
You might use the GA autotrack plugins instead (https://github.com/googleanalytics/autotrack) - while not an "offical" part of the product those are written by a Google engineer (who also maintains some presence at stackoverflow).
However it is easy to see if this works - Google offers the Google Tag Assistant (for Chrome) to test GA integrations, there is a Chrome GA Debugger Extension, or you might simply open the developer tools in your browser and inspect the "network" tab. If you filter for calls to google-analytics.com/collect you should see outgoing calls and can look at the query parameters to see if your data is sent properly; if the calls return a http status of 200 the data should turn up in your GA account.
Thanks to Eike's response I've now chosen to solve this challenge by installing Google Tag Manager and then creating custom tags to track things like outbound links, email links and download links. Here's a guide that helped me to setup download tracking, hope others find it useful.
My website is loading JS to links similar to this one:
https://api.mixpanel.com/engage?data=eyIkdG9rZW4iOiI2NTQwMDNjNmRkZDAzZTg4NzY0MTM4ZTYwMDQ1M2E2NyIsIiRkaXN0aW5jdF9pZCI6InBpZmdzaXVhcmhsbHFjOXRncGw1OTlqdXJmIiwiJHNCI6eyJ0eXBlIjoiZnJlZSIsImlzTW96YmFyT24iOmZhbHNlLCJpc0RvY2tlZE9uQm90dG9tIjpmYWxzZSwiYnJvd3NlciI6ImNocm9tZSIsIm9zIjoid2luZG93cyIsInBhZ2VPbmJvYXJkaW5nU3RlcCI6InBhZ2UtaG90c3BvdHMiLCJzZXJwT25ib2FyZGluZ1N0ZXAiOiJzZXJwLWhvdHNwb3RzIn19&ip=0&verbose=0
I cannot find where it is linked from. I saw the site mixpanel.com and looks like they offer a web analytics service or something similar, but I have not any with them. Have I being hacked? What can I do to find witch file is doing the request?
I am almost sure the request is not being made directly for my website; maybe is made by some plugin? How can I be sure? Should I remove it? How?
Mixpanel is a tracking and analytics provider. If your website is hosted on your very own server, controlled by only you, then things to try are:
1) Disable all your browser's extensions. Turn them all off, confirm that it's either still happening of has been resolved. If it's no longer happening, turn them on one by one.
2) Different internet connection. Some poor WiFi hotspots may inject tracking code.
3) Try a different browser like Firefox, Chrome, Safari....
If your website is hosted by someone like Wix, SquareSpace, Weebly, etc then this tracking is very likely injected at their level and you will probably not be able to turn this off, but you should be able to get access to the insights in your control panel.
Is is possible to leverage Google analytics code to get browser and devices data. Want to add this data to anonymous feedback widget.
We already use classic GA tracking so thought it might be an option to reuse whatever method they use for recording browser, os, device etc that's available in GA reports.
Basically every browser is a code that is scraping data from a website. If it can, you can too.
https://developers.google.com/analytics/devguides/reporting/
Scraping Real Time Visitors from Google Analytics
I recommend you use Google Analytics APIs for this purpose.
These are a few links that can help you.
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 anymore.
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"
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:
Download stats
SSL Support - If you link to an external image that
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.