views:

52

answers:

1

Let's say I run a site where customers are willing to pay for a page that shows some sort of cool info about them. The whole site is tracked using Google Analytics.

To provide stat tracking for the customers, would it be possible to mine the data from Google Analytics, using the AJAX API?

Are there any show-stoppers I should look out for before attempting this?

Trying to prevent from writing my own stat tracking solution.

Update, a bit more clarification: I'm looking to be able to build a stats page that shows a few stats for a specific url (page views, traffic sources, etc...), not necessarily in real-time. I would cache the page to prevent hitting API rate limits.

+2  A: 

There are 2 major impediments: One technological, and one legal-ish. Together, they make using Google Analytics Data Export API an unfit solution.

Technological: Google Analytics Data is not available in Real-Time. Delays in data processing run from 3-4 hours to 24-48 hours. Page-views are processed fasted; things like custom variables often take a day or so). In theory, you could tag each user with a custom variable, and then query against that custom variable for information.

Legal-ish The Google Analytics Terms of Service prohibits you from collecting personally identifiable information. So, you can't use a custom variable that stores their username on your site without violating the Terms of Service. Here's the relevant section.

  1. PRIVACY . You will not (and will not allow any third party to) use the Service to track or collect personally identifiable information of Internet users, nor will You (or will You allow any third party to) associate any data gathered from Your website(s) (or such third parties' website(s)) with any personally identifying information from any source as part of Your use (or such third parties' use) of the Service. You will have and abide by an appropriate privacy policy and will comply with all applicable laws relating to the collection of information from visitors to Your websites. You must post a privacy policy and that policy must provide notice of your use of a cookie that collects anonymous traffic data.

As far as alternatives, it depends on what information you want. You can access their IP address on the server side and use that with a third party tool or a command line call to find out their rough location (much the same way that Google does). You can similarly access their referer on the server side. Much of the information that gets sent to Google actually gets stored in the Analytics cookies (_utm prefixed cookies). There's a wide body of literature on reading these cookies (See: http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=how+to+parse+google+analytics+cookies)

yc
Hmm, theoretically, if I didn't care about real-time stats and only mined by a specific url (not a username) then I wouldn't hit the limitations you mentioned, correct? If all I wanted was to be able to create a page that showed a few stats about a specific url, this could work?
Chad
Yes, that would work, and it probably wouldn't violate the ToS. It would be pretty easy to query the API for that. If you wanted to query Visits and Pageviews for /admin.php and their sources, you'd set dimension to ga:pagePath,ga:source Metrics to ga:visits,ga:pageviews, and Filter to ga:pagePath==/admin.php . Test it out in their API Feed Query Explorer: http://code.google.com/apis/analytics/docs/gdata/gdataExplorer.html
yc
That works great. Thanks!
Chad
Or you could use another uniquely identifying value like a userid. Something that cannot personally identify the user or mean anything about the user outside of your own system. Like for instance, if my userid in your system is 12345 well that doesn't mean anything to anybody except yourself: it doesn't violate my privacy. So you can track that id in custom fields and then in your own system, match up the data from GA to your own system when showing stats for the appropriate person.
Crayon Violent
@Crayon Violent, I actually had the privilege to ask about that of one of the Project Managers of Google Analytics this week. Basically, it's still a violation (much to my disappointment), since its not just about preventing Google from having PII, but from allowing you to use GA to track PII.
yc