Analytics Methods

The Analytics API methods are used to export the type of data you see in your projects analytics pages from the project.

 

URL

api/external/analytics/{method_name}

Method Names

Method NameDescription
new_users Returns info on new users over a given time period
total_sessions Returns info on total sessions over a given time period
total_sessions_time Returns info on total session time over a given time period, the unit is seconds
avg_session_time Returns info on average session time over a given time period, the unit is seconds
unique_sessions Returns info on unique sessions over a given time period
locations_hits Returns info on location entries over a given time period
statistics Returns new users, addressable users, total sessions, total sessions time, avg session time, unique sessions in one request

Parameters

ParameterDescription
apptoken Your App token
totals Optional, set to 1 if getting totals i.e. "totals":1
params Optional, used to supply start and end dates in yyyy-mm-dd format as follows: "params":{"startDate": "2015-02-01", "endDate": "2015-02-28"} . If the time period is one day values will be returned per hour, if the time period is less than or equal to 30 days then the values will be returned per day, if the time period is greater than 30 days values will be returned per month, and if the time period is greater than a year values will be returned per year.

Examples

Get data for all time, values will be split by day, month or year depending on how long the "all time" time period is

curl -X POST -d '{"apptoken":"YOUR_APPTOKEN"}' https://external-api.xtremepush.com/api/external/analytics/{method_name}

Get data for all time giving the total

curl -X POST -d '{"apptoken":"YOUR_APPTOKEN", "totals":1}' https://external-api.xtremepush.com/api/external/analytics/{method_name}

Return data for a specific time period, in this example the time period is less than or equal to 30 days values will be returned per day

curl -X POST -d '{"apptoken":"YOUR_APPTOKEN", "params":{"startDate": "2015-02-01", "endDate": "2015-02-28"}}' https://external-api.xtremepush.com/api/external/analytics/{method_name}

Example call to get total number of new users for February 2015

curl -X POST -d '{"apptoken":"YOUR_APPTOKEN", "totals":1, "params":{"startDate": "2015-02-01", "endDate": "2015-02-28"}}'  https://external-api.xtremepush.com/api/external/analytics/new_users

Example call to get all time totals for new users, addressable users, total sessions, total sessions time, avg session time, unique sessions in one request:

curl -X POST -d '{"apptoken":"YOUR_APPTOKEN", "totals":1}' https://external-api.xtremepush.com/api/external/analytics/statistics

Example call to get total and unique location entries for all your locations:

curl -X POST -d '{"apptoken":"blahblah"}' https://external-api.xtremepush.com/api/external/analytics/locations_hits

Sample response from call to get all time unique sessions, the result split by month in this instance because the app has only been live for three months.

{
    "code": 200, 
    "data": {
        "periods": {
            "Feb/15": {
                "amount": "10000"
            }, 
            "Jan/15": {
                "amount": "11000"
            }, 
            "Mar/15": {
                "amount": "12000"
            }
        }
    }, 
    "message": "", 
    "success": true
}

Sample response from call to get all time total for unique sessions

{
    "code": 200, 
    "data": {
        "totals": {
            "amount": "33000"
        }
    }, 
    "message": "", 
    "success": true
}

Sample response from call to get analytics on new users from 1 - 28 of February 2015

{"data":{"periods":{"01-Feb":{"amount":10},"02-Feb":{"amount":11},"03-Feb":{"amount":56},"04-Feb":{"amount":44},"05-Feb":{"amount":38},"06-Feb":{"amount":77},"07-Feb":{"amount":68},"08-Feb":{"amount":99},"09-Feb":{"amount":45},"10-Feb":{"amount":63},"11-Feb":{"amount":23},"12-Feb":{"amount":"75"},"13-Feb":{"amount":44},"14-Feb":{"amount":56},"15-Feb":{"amount":78},"16-Feb":{"amount":45},"17-Feb":{"amount":54},"18-Feb":{"amount":37},"19-Feb":{"amount":41},"20-Feb":{"amount":38},"21-Feb":{"amount":42},"22-Feb":{"amount":65},"23-Feb":{"amount":83},"24-Feb":{"amount":23},"25-Feb":{"amount":88},"26-Feb":{"amount":97},"27-Feb":{"amount":104},"28-Feb":{"amount":121}}},"code":200,"message":"","success":true}

Sample response from call to to get total number of new users for February 2015

{
    "code": 200, 
    "data": {
        "totals": {
            "amount": "1015"
        }
    }, 
    "message": "", 
    "success": true
}

Sample response from a call to get totals using the statistics call

{
    "code": 200, 
    "data": {
        "avg_session_time": {
            "totals": {
                "amount": 125
            }
        }, 
        "new_users": {
            "totals": {
                "amount": "5760"
            }
        }, 
        "total_sessions": {
            "totals": {
                "amount": "20450"
            }
        }, 
        "total_sessions_time": {
            "totals": {
                "amount": "2556250"
            }
        }, 
        "unique_sessions": {
            "totals": {
                "amount": "5749"
            }
        }
    }, 
    "message": "", 
    "success": true
}

Example response showing location entries for the locations with ids 1293, 1345 and 1347:

{
    "code": 200, 
    "data": {
        "1293": {
            "amount": "75000", 
            "amount_unique": "36000"
        }, 
        "1345": {
            "amount": "475000", 
            "amount_unique": "237983"
        }, 
        "1347": {
            "amount": "44", 
            "amount_unique": "1"
        }
    }, 
    "message": "", 
    "success": true
}
Have more questions? Submit a request

0 Comments

Article is closed for comments.