Google Analytics for third-party embedded widget - javascript

I've been able to test this to a certain extent within our application, however I'm still testing the waters with google analytics to see if it is the best choice for app analytics; for externally embedded javascript.
I'm able to fire custom events, and custom page views. However I'd like to see all online users across all sites that have the widget embedded on. It currently shows online users, but it uses a relative URL path, instead of the domain or full path.
The type of data points I'm hoping to gather are specific interactions the user makes with the application, as well as live statistics which can be drilled down to the publisher of the embed.
Has anyone had experience using google analytics for third party embeds? or is there another service out there that is better suited for app analytics of this nature?

Related

Browser and devices data from Google analytics code

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.

google analytics tracking link clicks

I was wondering how would i go about adding a simple tracking to a certain link on a site I am developing for a client
I am using google analytics for tracking the source of the incoming traffic and after the visitor has entered the site he supposed to click on a link, I an interested in knowing how many clicks I got from every source.
You're looking for "Campaigns". There's an extensive article about it here: http://support.google.com/analytics/bin/answer.py?hl=en&answer=1239239
You can use the "URL Builder" tool to create a URL for a specific link (on an external site, presumably) by giving a name to your campaign and other details. The parameters are utm_source, utm_medium, and utm_campaign in particular.
I'll mention that Analytics will already tell you (without any modification to the link) what referring page sent a visitor, so you can tell what page a visitor was viewing before arriving at your site. All this is found under "Traffic Sources" in the Analytics reporting interface. The utility of campaigns is if either (a) you'll be scattering links in ads on many different websites, and it's the ad rather than the page that you want to track, or (b) there may be multiple links to your site on the same page and you want to know which one the visitor clicked.

How to monitor a single page web app?

I wonder how one would monitor a single page web app so you can see what the user does in your app, what "pages" he visited etc.
Kinda like Google Analytics with statistics for a lot of things.
Google Analytics is great for this. Check out custom events: http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html
It takes a fair amount more work than the "set it and forget it" type tracking you can do with traditional websites, but it's also pretty easy.
It will not 'just work', you need to be calling trackPageView to make the requests count as pageviews and include all the visitor information that would be included (not trackEvent). This gist is an old but popular solution to ajax navigation showing how to call trackPageView. It is called right after the content from the new url is injected into the page, so an equivalent in a framework like Backbone.js would on view initialization, like suggested in this guide.

How do I track visits to facebook pages using Google Analytics or Yahoo Web Analytics?

I have recently looked into this and discovered that using FBML pages in a facebook fan page, I can add fb:google-analytics tags or image tags to track page visits. However I have found no method of tracking visits to other facebook tab pages, like "pictures" or "wall".
Is there a way do this?
Thanks
There is no way of doing this with Google Analytics.
There used to be a hack that embedded a php file as an image, and that request tracked a pageview. However, a change to how Facebook renders pages makes this hack/plugin useless (it looks like it stopped working on September 7th). Basically, it looks like they're caching any external images onto their own servers, and thus breaking this hack. Short of there being an officially supported plugin, or Facebook allowing Google to track more, this is likely a dead end.
Edit: With Facebook tabs, you can install an iframe app as a tab (not using FBML), and you can put Google Analytics on the tab. But, since its an iframe, you don't have access to real referrer information, and Facebook spoofs its referrer, so there's no way for the iframe to detect anything about the page. But this is only for the tab, not for the wall or photos.
Another important thing to note is that the cookies are still being set on your domain, so it might make sense to keep the account on your main account, but use a special configuration on the tab.
Here's the best practice I've settled on for putting Google Analytics on a Facebook tab iframe:
First, the iframe URL should contain the URL parameter ?utm_nooverride=1. This is so if the user already has referral cookies (for example, if they got to your site before via Google, the pageview will persist with that referral source.)
Second, I override the referrer value (which is useless, since it is spoofed by Facebook) to be tab.facebook.com, to make it simple to differentiate from other traffic.
Finally, I place 2 custom variables: One page-level, and one visitor level. The former allows me to easily know what pageviews occurred from within the tab. The second allows me to track the rest of the interactions my site has with this person if they end up returning to my site. That code looks like this:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-1']);
_gaq.push(['_setReferrerOverride', 'http://www.tab.facebook.com']);
_gaq.push(['_setCustomVar', 1, 'is_facebook_page', 'true', 3]);
_gaq.push(['_setCustomVar', 2, 'visited_facebook', 'true', 1]);
_gaq.push(['_trackPageview']);
Facebook does provide some limited analytics capabilities called Facebook Insights:
http://www.facebook.com/help/?faq=15221
Also outgoing links will be tagged with a tracking code so you can pick up which traffic is coming from your Facebook pages to your site.
However you cannot embed Google Analytics or Yahoo Analytics directly into the pages.

Google Analytics to track FireFox extension use

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:

Categories