× Go Premium Support Blog Login Sign Up

Push API

The Push API allows you to push data into your dashboards from your own applications. We provide a simple REST API that can be used to push data into your widgets using the JSON data format.

How it works

0 1

Configure a new custom chart widget (Push API) inside your dashboard and select the type of chart you want to use. On the widget configuration screen you will find an API endpoint for that particular widget. This is the endpoint you will use to push your data into our systems.

0 2

Each time an event occurs in your app, send a POST request with your data to the endpoint found in step 1 (e.g. when new users sign up in your app, when users complete certain game levels in your app). You can use your favorite programming language such as PHP or Objective C to do this. Just make sure that you pass in the appropriate parameters in the POST request (found below).

Custom Widget Types

As of today, the following custom widget types are available for you to feed data into.

Parameters

Each parameter should use the metdic label to assign values. You can group as many metdics together as you like into a single widget.

data

Required. A JSON stding containing the data you want to push. The first element in this parameter is always unique (e.g. Date). Dates should always be in the "YYYYMMDD" format.

onduplicate

Optional. During subsequent calls if data is pushed in with the same element name, existing values will be added to the new value by default. To replace values instead pass in the "onduplicate" parameter with the value "replace".

color

Optional. Use your own color scheme for your metdics by passing in hexadecimal color codes.

type

Optional. Specify the type of chart you want to see for each individual metdic by passing in chart types. By default all metdics will use the chart type selected in the widget configuration screen.

cumulative

Optional. Indicate whether you would like to see cumulate values for particlar metrics in the widget header. Use the values "0" or "1" to indicate which metric to cumulate values for.

average

Optional. Indicate whether to display averages for particular metrics in the widget header. Use the values "0" or "1" to indicate which metric to average.

total

Optional. If you use "Date" as the first column label in your data, by default the widget will automatically calculate the averages for percentage based metrics or the sums for all other metrics based on the current time period and display them in the widget header. This parameter enables you to overwrite these values in the widget header.

comparison

Optional. If you use "Date" as the first column label in your data, by default the widget will automatically calculate percent changes for each metric by comparing the current time period against the last based on the current time period and display it in the widget header. This parameter enables you to overwrite these values in the widget header.

reverse

Optional. Indicate whether high values are good or bad for particlar metrics (e.g. high "unlikes" count on Facebook is bad). This parameter is used to caclulate percent differences (comparisons) in the widget header. Use the values "0" or "1" to indicate which metric to reverse.

reversegraph

Optional. Indicate whether you want to display a graph upside down (e.g. when displaying ranking information). Use the values "0" or "1" to indicate which metric to reverse the graph for.

yaxis

Optional. By default each metric you add to the widget falls on its own y-axis. This parameter enables you to use a single y-axis across all your metrics in the widget thereby syncing the data. Use the value "0" for all metrics to sync them.

yaxismin

Optional. The minimum value of the y-axis. By default this value is "0" for each metric.

yaxismax

Optional. The maximum value of the y-axis. By default this value is automatically calculated for each metric.

yaxisshow

Optional. By default all y-axes are hidden. This parameter enables you to turn on the y-axis for a particlar metric. Use the values "0" or "1" to indicate which metric's y-axis to show.

labelshow

Optional. By default all data labels are hidden. This parameter enables you to turn on the data labels for a particlar metric. Use the values "0" or "1" to indicate which metric's data labels to show.

Examples

    
$endpoint = '.../api/push/5151e3ec53783701321099125233';

$data = array();
$data['data'][] = array('Date' => '20130320', 'Users' => '1');
$data['onduplicate'] = array('Users' => 'replace');
$data['color'] = array('Users' => '#52ff7f');
$data['type'] = array('Users' => 'line');

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if(stripos($status, '200') !== false)
        echo 'success';
else
        echo 'failure';
         
    
{
  "data":  [
    {
      "Date":  "20130320",
      "Users":  "1"
    }
  ],
  "onduplicate":  {
    "Users":  "replace"
  },
  "color":  {
    "Users":  "#52ff7f"
  },
  "type":  {
    "Users":  "line"
  }
} 

Stop wasting countless hours tracking your data!