Over a million developers have joined DZone.

Google Analytics for REST APIs

Google Analytics provides great real-time and historical reports for websites, and with WSO2 API Cloud, you can easily get them to report your REST API usage as well.

· Integration Zone

Build APIs from SQL and NoSQL or Salesforce data sources in seconds. Read the Creating REST APIs white paper, brought to you in partnership with CA Technologies.

Google Analytics provides great real-time and historical reports for websites, and with WSO2 API Cloud, you can easily get them to report your REST API usage as well.

To do that you simply have to:

  1. Create a tracking ID in Google Analytics.

  2. Configure WSO2 API Cloud to report to Google Analytics and provide the ID.

  3. See real-time and historical API usage reports.

Let’s go through all of these steps in details.

1. Create a Tracking ID in Google Analytics

This is not really specific to WSO2 API Cloud in any way. You basically create a Google Analytics account like you normally would.

1a. Go to the Google Analytics homepage and log in or sign up.

1b. Click the Admin tab.

Admin menu in Google Analytics

1c. From the Accounts dropdown, select Create new account.

Create new Google Analytics account

1d. Provide the name of the account and site as you see fit. For the website URL, either provide the custom URL that you have configured in API Cloud or just gateway.api.cloud.wso2.com if you have not done so.

Setting up Google Analytics account

1e. Click the Get Tracking ID button and accept terms and conditions, and Google Analytics will get you to the Tracking ID page of the new account. Right at the top of the page, it will have the ID that you need, i.e., UA-12345678-9.

2. Hook Up WSO2 API Cloud and Google Analytics

2a. From your API Publisher view, copy your domain-qualified ID that is displayed in the top-right corner.

Copy domain-qualified WSO2 Cloud username

2b. Go to advanced Gateway admin console here.

2c. Sign in with the domain-qualified name that you got in Step 1 and your regular password.

Gateway sign-in

2d. In the left-hand pane, click Resources/Browse.

2e. Browse to /_system/governance/apimgt/statistics/ga-config.xml:.

Resources Browse to GA analytics configuration

2f. Click edit as text.

Edit as text

2g. Change false to true, copy and paste the TrackingID that you got when setting up the Google Analytics account, and click Save Content:

Editing Google Analytics config

That is it. Now all API calls for your APIs get registered in Google Analytics.

3. Enjoy Google Analytics Reports for APIs

Once the configuration changes go into effect, your usage data will start showing up in Google Analytics reports.

Real-time Google Analytics API report

Real-time report shows subscribers invoking your API right now

Behavior Overview Google Analytics report for APIs

Behavior reports can show trends over time, popular REST paths, and so on

And of course, you can use various Google Analytics functionality to work with trends, grouping, custom reports, filtering, and so on.

The Integration Zone is brought to you in partnership with CA Technologies.  Use CA Live API Creator to quickly create complete application backends, with secure APIs and robust application logic, in an easy to use interface.

api cloud,rest apis,google analytics,integration

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}