Recording Statistics

Statistics can be gathered and recorded using the Record Statistic API method. However, some statistics like “views” (the number of times users have viewed an app) can be recorded automatically by OpenChannel. The OpenChannel statistics engine is generic. This means that you can record any statistic and OpenChannel will be able to return a total and time series based on the “field” that you specify.

For example, if you were interested in keeping track of how many times a user clicked a “Learn More” button on your app details page then you would be able to track that statistic by setting the field parameter as “learn”.

An example of tracking a custom statistic called “learn”:

curl --user {marketplaceId}:{secret} https://market.openchannel.io/v2/stats/increment/learn 
  -X POST 
  -d appId=5565322ae4b0a70b13a4563b 
  -d value=1 

 

Displaying Total Statistics

A sum of statistics can be returned for any app statistic recorded within your marketplace. This is useful when displaying statistical totals for developers. The response includes the sum for each individual app that satisfies the query as well as a grand total.

An example of retrieving the view and download totals for the developer with id “123”:

curl --user {marketplaceId}:{secret} https://market.openchannel.io/v2/stats/total? 
  start=1455062400000& 
  end=1457568000000& 
  fields=views,downloads& 
  query={'developerId':'123'}

An example of retrieving a custom field total for the app with id “551569dde4b09c3f7fe5461f”:

curl --user {marketplaceId}:{secret} https://market.openchannel.io/v2/stats/total? 
  start=1455062400000& 
  end=1457568000000& 
  fields=learn& 
  query={'appId':'551569dde4b09c3f7fe5461f'}

 

Displaying Time Series Statistics

A time series can be returned for any app statistic recorded within your marketplace and is returned as an array of date and value pairs. This is useful when displaying statistics charts for developers.

An example of retrieving a daily view time series for the developer with id “123”:

curl --user {marketplaceId}:{secret} https://market.openchannel.io/v2/stats/series/day/views? 
  start=1455062400000& 
  end=1457568000000& 
  query={'developerId':'123'}

An example of retrieving a monthly download time series for the app with id “551569dde4b09c3f7fe5461f”:

curl --user {marketplaceId}:{secret} https://market.openchannel.io/v2/stats/series/month/downloads? 
  start=1455062400000& 
  end=1457568000000& 
  query={'appId':'551569dde4b09c3f7fe5461f'}

Displaying a Time Series Chart with Flot

Displaying a time series is much easier with the help of javascript graphing libraries such as Flot. In fact, no changes to the API response are needed and can be plugged directly into Flot’s data parameter. Notice the “statisticsApiResponse” variable on the last line – that is the response object from the OpenChannel Timeseries API.

An example of the HTML required to implement a time series graph using Flot:

<div id="plot"></div>

An example of the Javascript required to implement a time series graph using Flot:

var settings = {
	yaxis: {
		min: 0,
	},
	xaxis: {
		mode: "time",
		tickSize: [2, "month"],
		monthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
		tickLength: 0
	}
};

jQuery.plot("#plot", [{ data: statisticsApiResponse }], settings);