问题
I've build a web based on Java using Spring MVC (database MySQL) . Now I'd like to add web analytic functionalities on it. For example, I need to know the duration of each session by user, what kind of transaction performed the most. etc.
What kind of API I can use for this ? Is Spring XD or Google Analytic the one I am looking for ?
回答1:
You need to install Google Analytics on your pages. Place JavaScript snippet on every page of your application: https://developers.google.com/analytics/devguides/collection/analyticsjs/
You can track transaction via Tracking API. You can use JavaScript API or generic Measurement Protocol. You need to set up events: https://developers.google.com/analytics/devguides/collection/analyticsjs/events .
You can get reports via Core Reporting API: https://developers.google.com/analytics/devguides/reporting/core/v3/ . Here is Java Quickstart: https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/service-java
来源:https://stackoverflow.com/questions/33207846/web-analytic-api-for-java