Thursday, November 10, 2016

Google Analytics Tracking for WSO2 App Manager

Google Analytics is a free Web analytics service that provides statistics and basic analytical tools. We can configure WSO2 App Manager to track web application and sites invocation statistics through Google Analytics.

First, let's see how to setup a google Analytic account.

1. Go to and Click on Analytic tab.
2. Then, click on "Admin" tab and create a New Account.
3. Click on "Website" and give account information like in below. Here, you have to fill the information which you want to track.
4. Click on 'Get Tracking Id'. Then you will redirect to a page like below. From there you can get the Tracking Id.
5.  Configure WSO2 App Manager with received Tracking code. Enable google analytics and add TrackingID of <APPM_HOME>/repository/conf/app-manager.xml as shown below.
 <!--Enable/Disable Google Analytics Tracking-->  
      <!--Google Analytics Tracking ID-->  
6. Restart server.
7. Place the below JavaScript code snippet into the pages that you need to track with your Google Analytics account.
 <script language="javascript" src="" type="text/javascript">  
   function invokeStatistics(){      
   var tracking_code = ["<TRACKING_CODE>"];      
   var request = $.ajax({      
     url: "http://<AM_GATEWAY_URL>:8280/statistics/",      
     type: "GET",      
     headers: {        

Now we have successfully integrated WSO2 App Manager with Google Analytics. Let's see how we can see the statistics.

Real-time statistics

Then go to Google Analytics [] and select the created account above.

The following image shows an invocation of a specific Web application. The Google Analytics graphs and statistics are displayed at runtime in its Real-Time view. In below graphs, you will able to see a hit on "PageViews" per second and active users.

Reporting statistics

Google Analytics reporting statistics will take more than 24 hours from the time of invocation.

A sample dashboard with populated statistics is shown in below.

No comments:

Post a Comment