WSO2 API Manager can be configured to track runtime statistics of API invocations through Google Analytics (http://www.google.com/analytics). Google Analytics is a service which allows you to track visits to a website and generate detailed statistics.
This guide explains how to setup API Manager in order to feed runtime statistics for summarization and display to Google analytics.
1. Setup a Google Analytics account if not subscribed already and receive a Tracking ID, which is of the format "UA-XXXXXXXX-X". A Tracking ID is issued at the time an account is created with Google Analytics.
2. Open $AM_HOME/repository/conf/api-manager.xml. Enable the <GoogleAnalyticsTracking> element and enter the Tracking-ID.
<GoogleAnalyticsTracking> <!-- Enable/Disable Google Analytics Tracking --> <Enabled>false</Enabled> <!-- Google Analytics Tracking ID --> <TrackingID>UA-XXXXXXXX-X</TrackingID> </GoogleAnalyticsTracking>
3. Save the file and restart the API Manager instance.
4. API Manager is now integrated with Google Analytics. A user who has subscribed to a published API through the API Store should see an icon as "Real-Time" after logging into their Google Analytics account. Click on this icon and select "Overview".
5. Then invoke the above API through the embedded WSO2 REST Client (or any third-part rest client such as cURL).
Real-Time Statistics
6. This is an invocation of the API. Accordingly, Google Analytics graphs and statistics will be displayed on runtime. In this case it will be a hit on 'PageViews' Per second graph and also 1 user active as shown in the screenshot below.
Reporting Statistics
Google Analytics reporting statistics population takes more than 24 hours from the time of invocation. Shown below is a sample Dashboard with populated statistics.
Note that there are Widgets with statistics related to Audience, Traffic, Page Content, Visit Duration etc. You can add any widget of your preference through 'Add Widget'.