可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
Just wondering if there's any out of the box solution for this, I am not too familiar with the analytics api maybe I can write some simple js that updates analytics before going to my service etc. -- otherwise I am going to have to stick to the good old 'store records in the database'.
Any help appreciated!
回答1:
There seem to be a few solutions out there, though they mostly seem to involve changing your API architecture.
- Apigee
- Mashery
- 3scale
- ReportGrid
You could potentially use one of the Google Analytics server-side tracking libraries.
I see you're using AppEngine; I also run an API using AppEngine, and recently have been playing with using a Google Analytics Library for App Engine. It's not a perfect solution, but there's a decent amount of quality data.
Be warned that Google Analytics data modeling really isn't that analagous to that of an API; depending on your API, the notion of a "visit" is somewhat meaningless.
回答2:
I think Keen IO would be a great fit here. It's an API-only analytics platform (meaning that you both send data and consume analysis via a REST API).
Full disclosure: I'm the CEO. I'm not writing this answer to self-promote, but because honestly, our product was purpose-built for use cases like yours.
Several Keen IO users are API companies who use it to do analytics on how their users are using their APIs.
At the risk of being a bit too meta: We use the Keen IO API internally to collect events and perform analysis of how our customers use the Keen IO API externally, and by way of example, our two-event data model looks something like this:*
- analysis_call
- request (object)
- client_library_version (string)
- API_version (number)
- query_parameters (key-value object)
- post_parameters (key-value object)
- origin_ip (ip address)
- URI (string)
- num_events (integer)
- includes_geolocation (boolean)
- user_agent (string)
- response (object)
- HTTP_code (number)
- latency (number)
- headers (object)
- body (object: the actual full JSON response object, if under 1K)
- events_added_call
- client_library_version (string)
- API_version (number)
- origin_ip (ip address)
- request (object)
- response (object: the actual full JSON response object)
*We actually use a lot more properties than this, I've stripped them out to make this more clear
回答3:
Well, you could use...google analytics
On the server, in a REST API handler function, make an HTTP GET request to http://www.google-analytics.com/__utm.gif with the right parameters, and you're done. Preferably async.
https://developers.google.com/analytics/resources/concepts/gaConceptsTrackingOverview
回答4:
You could do this now with GA using the new Measurement Protocol the is currently in public beta.
回答5:
I think what you're looking for is something like apigee: http://apigee.com
回答6:
What information are you looking for specifically? You might be able to get what you need from http access logs.
回答7:
I don't think google analytics can track rest calls, because it's activated by a snippet of JavaScript that you embed in your HTML.
To view the logs, you can go to the appengine console, choose your application and select Logs.
To access your logs programmatically, you've to download them (with Java, with Python), but it seems that up to now you can't do it within your app engine, so you've to do it either on your workstation or maybe on an Amazon EC2 (maybe micro) instance.
On the other hand, if you decide to store records in the DataStore, do the update within a task queue, so you don't slow down your API (Task Queues with Java, Task Queues with Python).
回答8:
I think this solution might be a really good choice if you're interested in specifically tracking REST calls: http://apianalytics.com
It looks like it has everything you'd need. A bit like the Mixpanel of APIs.
Disclaimer: A good friend of mine has built this