- Default aggregation with no grouping
- Default aggregation with one grouping
- Default aggregation with two groupings
- Aggregation
- Aggregation with one grouping
- Aggregation with two grouping
- Error handling
As you have already explored the data attributes and the query parameters, now let's have a look at the response that you will receive for a given API request. The response is returned in the JSON format. It contains a data array with multiple objects enclosed within curly brackets. You can refer to an object in this case as a new row. Two objects are separated by a comma. Each object contains multiple properties in key-value pairs.
The following section explains responses for various request types.
1.1 Default aggregation with no grouping
Example: Give me count of events and count of unique users in those events.
Parameters:
- daterange
Operations:
- Filter applied on daterange.
In this example, the request is made on the event data, where no grouping, as well as aggregation parameter, is passed to the API. For cases where the aggregation is not performed explicitly, default aggregations are returned in the response.
https://api.uxcam.com/event/analytics?
appid=60f6c0b8b97ba419120b82eb&
apikey=9c633412-927a-4f4e-87bc-386dc1e3a618&
daterange={"from": "2022-01-01", "to": "2022-03-02"}
- event_count: Default aggregation
- event_unique_user_count: Default aggregation
- event_unique_session_count: Default aggregation
- dashboard_link: URL to the UXCam dashboard
{
"success": true,
"data": [
{
"event_count": 63,
"event_unique_user_count": 16,
"event_unique_session_count": 35,
"dashboard_link": "https://app.uxcam.com/app/5e96a0513596b900b44eeafa/events/list/1?dateRange={\"from\":\"2020-07-25\",\"to\":\"2020-10-30\"}"
}
]
1.2 Default aggregation with one grouping
Example: Give me the count of unique users by country name.
Parameters:
- daterange
- session_country
Operations:
- Filter applied on daterange.
- Grouping done on session_country.
In this example, the request is made on the session data, where one grouping parameter is passed to the API while there is no aggregation. For cases where the aggregation is not performed explicitly, default aggregations are returned in the response.
https://api.uxcam.com/session/analytics?
appid=60f6c0b8b97ba419120b82eb&
apikey=9c633412-927a-4f4e-87bc-386dc1e3a618&
daterange={"from": "2022-01-01", "to": "2022-03-02"}&
group_by=[{"attribute":"session_country"}]
- session_count: Default aggregation
- session_new_user_count: Default aggregation
- session_unique_user_count: Default aggregation
- session_country: Grouping
- dashboard_link: URL to the UXCam dashboard
{
"success": true,
"data": [
{
"session_count": 25,
"session_country": "Canada",
"session_new_user_count": 7,
"session_unique_user_count": 9,
"dashboard_link": "https://app.uxcam.com/app/5e96a0513596b900b44eeafa/sessions/list/1?dateRange={\"from\":\"2020-10-25\",\"to\":\"2020-10-30\"}&country={\"o\":\"in\",\"v\":[\"Canada\"]}"
},
{
"session_count": 12,
"session_country": "United Kingdom",
"session_new_user_count": 2,
"session_unique_user_count": 5,
"dashboard_link": "https://app.uxcam.com/app/5e96a0513596b900b44eeafa/sessions/list/1?dateRange={\"from\":\"2020-10-25\",\"to\":\"2020-10-30\"}&country={\"o\":\"in\",\"v\":[\"United Kingdom\"]}"
},
{
"session_count": 11,
"session_country": "Germany",
"session_new_user_count": 3,
"session_unique_user_count": 5,
"dashboard_link": "https://app.uxcam.com/app/5e96a0513596b900b44eeafa/sessions/list/1?dateRange={\"from\":\"2020-10-25\",\"to\":\"2020-10-30\"}&country={\"o\":\"in\",\"v\":[\"Germany\"]}"
},
{
"session_count": 8,
"session_country": "Singapore",
"session_new_user_count": 2,
"session_unique_user_count": 3,
"dashboard_link": "https://app.uxcam.com/app/5e96a0513596b900b44eeafa/sessions/list/1?dateRange={\"from\":\"2020-10-25\",\"to\":\"2020-10-30\"}&country={\"o\":\"in\",\"v\":[\"Singapore\"]}"
},
{
"session_count": 5,
"session_country": "United States of America",
"session_new_user_count": 0,
"session_unique_user_count": 2,
"dashboard_link": "https://app.uxcam.com/app/5e96a0513596b900b44eeafa/sessions/list/1?dateRange={\"from\":\"2020-10-25\",\"to\":\"2020-10-30\"}&country={\"o\":\"in\",\"v\":[\"United States of America\"]}"
}
]
}
1.3 Default aggregation with two grouping
In this example, the request is made on the session data with two groupings.
Example: Give me the count of unique users by country name and device model.
Parameters:
- daterange
- session_country
- device_model
Operations:
- Filter applied on daterange.
- Grouping done on session_country and device_model.
https://api.uxcam.com/session/analytics?
appid=60f6c0b8b97ba419120b82eb&
apikey=9c633412-927a-4f4e-87bc-386dc1e3a618&
daterange={"from": "2022-01-01", "to": "2022-03-02"}&
group_by=[{"attribute":"session_country"}, {"attribute":"device_model"}]
- session_count: Default aggregation
- session_new_user_count: Default aggregation
- session_unique_user_count: Default aggregation
- session_country: First grouping
- device_model: Second grouping
- dashboard_link: URL to the UXCam dashboard
{ "success": true, "data": [ { "session_count": 18, "session_country": "Canada", "device_model": "MotoG3", "session_new_user_count": 6, "session_unique_user_count": 7, "dashboard_link": "https://app.uxcam.com/app/5e96a0513596b900b44eeafa/sessions/list/1?dateRange={\"from\":\"2020-10-25\",\"to\":\"2020-10-30\"}&country={\"o\":\"in\",\"v\":[\"Canada\"]}&devicemodel={\"o\":\"in\",\"v\":[\"MotoG3\"]}" }, { "session_count": 7, "session_country": "Canada", "device_model": "SM-G930P", "session_new_user_count": 1, "session_unique_user_count": 2, "dashboard_link": "https://app.uxcam.com/app/5e96a0513596b900b44eeafa/sessions/list/1?dateRange={\"from\":\"2020-10-25\",\"to\":\"2020-10-30\"}&country={\"o\":\"in\",\"v\":[\"Canada\"]}&devicemodel={\"o\":\"in\",\"v\":[\"SM-G930P\"]}" }, { "session_count": 0, "session_country": "Canada", "device_model": "iPhone 6s Plus", "session_new_user_count": 0, "session_unique_user_count": 0, "dashboard_link": "https://app.uxcam.com/app/5e96a0513596b900b44eeafa/sessions/list/1?dateRange={\"from\":\"2020-10-25\",\"to\":\"2020-10-30\"}&country={\"o\":\"in\",\"v\":[\"Canada\"]}&devicemodel={\"o\":\"in\",\"v\":[\"iPhone 6s Plus\"]}" } ] }
1.4 Aggregation
Example: Give me the average length of sessions.
Parameters:
- daterange
- session_duration
Operations:
- Filter applied on daterange.
- Aggregation done on session_duration.
In this example, the aggregation parameter is explicitly passed to the API request and the aggregation is done on session_duration using the average function.
https://api.uxcam.com/event/analytics?
appid=60f6c0b8b97ba419120b82eb&
apikey=9c633412-927a-4f4e-87bc-386dc1e3a618&
daterange={"from": "2022-01-01", "to": "2022-03-02"}&
- avg_session_duration: Aggregation
- dashboard_link: URL to the UXCam dashboard
{
"success": true,
"data": [
{
"avg_session_duration": 25.785571696,
"dashboard_link": "https://app.uxcam.com/app/5e96a0513596b900b44eeafa/sessions/list/1?dateRange={\"from\":\"2020-07-30\",\"to\":\"2020-10-30\"}"
}
]
}
1.5 Aggregation with one grouping
Example: Give me the total length of sessions for each applicable country.
Parameters:
- daterange
- session_duration
Operations:
- Filter applied on daterange.
- Aggregation done on session_duration.
- Grouping done on session_country.
In this example, the aggregation parameter is explicitly passed to the API request with one grouping. As in the above example, aggregation operation is performed on session_duration but using the sum function.
https://api.uxcam.com/session/analytics?
appid=60f6c0b8b97ba419120b82eb&
apikey=9c633412-927a-4f4e-87bc-386dc1e3a618&
daterange={"from": "2022-01-01", "to": "2022-03-02"}&
aggregation=[{'attribute':'session_duration','operator':'sum'}]&
group_by=[{"attribute":"session_country"}]
- sum_session_duration: Aggregation
- session_country: Grouping
- dashboard_link: URL to the UXCam dashboard
{
"success": true,
"data": [
{
"session_country": "Canada",
"sum_session_duration": 682.4,
"dashboard_link": "https://app.uxcam.com/app/5e96a0513596b900b44eeafa/sessions/list/1?dateRange={\"from\":\"2020-07-30\",\"to\":\"2020-10-30\"}&country={\"o\":\"in\",\"v\":[\"Canada\"]}"
},
{
"session_country": "Germany",
"sum_session_duration": 551.361920125,
"dashboard_link": "https://app.uxcam.com/app/5e96a0513596b900b44eeafa/sessions/list/1?dateRange={\"from\":\"2020-07-30\",\"to\":\"2020-10-30\"}&country={\"o\":\"in\",\"v\":[\"Germany\"]}"
},
{
"session_country": "United Kingdom",
"sum_session_duration": 344.578,
"dashboard_link": "https://app.uxcam.com/app/5e96a0513596b900b44eeafa/sessions/list/1?dateRange={\"from\":\"2020-07-30\",\"to\":\"2020-10-30\"}&country={\"o\":\"in\",\"v\":[\"United Kingdom\"]}"
}
]
}
1.6 Aggregation with two groupings
Example: Give me the total length of sessions for each applicable country and device manufacturer.
Parameters:
- daterange
- session_duration
Operations:
- Filter applied on daterange.
- Aggregation done on session_duration.
- Grouping done on session_country and device_manufacturer.
In this example, the aggregation parameter is explicitly passed to the API request with two groupings. As in the above example, aggregation operation is performed on session_duration using the sum function.
https://api.uxcam.com/session/analytics?
appid=60f6c0b8b97ba419120b82eb&
apikey=9c633412-927a-4f4e-87bc-386dc1e3a618&
daterange={"from": "2022-01-01", "to": "2022-03-02"}&
aggregation=[{'attribute':'session_duration','operator':'sum'}]&
group_by=[{"attribute":"session_country"},{"attribute":"device_manufacturer"}]
- sum_session_duration: Aggregation
- session_country: First grouping
- session_device_maufacturing : Second grouping
- dashboard_link: URL to the UXCam dashboar
{
"success": true,
"data": [
{
"session_country": "Canada",
"device_manufacturer": "samsung",
"sum_session_duration": 198.78,
"dashboard_link": "https://app.uxcam.com/app/5e96a0513596b900b44eeafa/sessions/list/1?dateRange={\"from\":\"2020-07-30\",\"to\":\"2020-10-30\"}&country={\"o\":\"in\",\"v\":[\"Canada\"]}&devicemanufacturer={\"o\":\"in\",\"v\":[\"samsung\"]}"
},
{
"session_country": "Canada",
"device_manufacturer": "Apple",
"sum_session_duration": 0,
"dashboard_link": "https://app.uxcam.com/app/5e96a0513596b900b44eeafa/sessions/list/1?dateRange={\"from\":\"2020-07-30\",\"to\":\"2020-10-30\"}&country={\"o\":\"in\",\"v\":[\"Canada\"]}&devicemanufacturer={\"o\":\"in\",\"v\":[\"Apple\"]}"
},
{
"session_country": "Germany",
"device_manufacturer": "Apple",
"sum_session_duration": 522.68,
"dashboard_link": "https://app.uxcam.com/app/5e96a0513596b900b44eeafa/sessions/list/1?dateRange={\"from\":\"2020-07-30\",\"to\":\"2020-10-30\"}&country={\"o\":\"in\",\"v\":[\"Germany\"]}&devicemanufacturer={\"o\":\"in\",\"v\":[\"motorola\"]}"
},
{
"session_country": "Germany",
"device_manufacturer": "samsung",
"sum_session_duration": 0,
"dashboard_link": "https://app.uxcam.com/app/5e96a0513596b900b44eeafa/sessions/list/1?dateRange={\"from\":\"2020-07-30\",\"to\":\"2020-10-30\"}&country={\"o\":\"in\",\"v\":[\"Germany\"]}&devicemanufacturer={\"o\":\"in\",\"v\":[\"samsung\"]}"
}
}
}
1.7 Error Handling
When there are errors, you won’t receive the correct responses described above. In such cases, it is important to understand the cause of the errors. UXCam server issues a status code for every request made. You can relate to the type of error by comparing with the status code as shown in the table below:
Status Code | Reason | Description | |
---|---|---|---|
1 | 200 | OK | Everything worked fine |
2 | 400 | Bad request | The request contained an unexpected or bad parameter |
3 | 401 | Unauthorized request | No valid API or appid key provided |
4 | 402 | Request failed | The parameters were valid but the request is Invalid |
5 | 403 | Forbidden request | The API key or appid doesn't have permissions to perform the request |
6 | 404 | Not found | The requested resource doesn't exist |
7 | 429 | Request limit exceeded | Too many requests |
8 | 500, 502, 503, 504 | Server side error | Something wrong on the server |
Note: The API server limits the concurrent requests to 5 at all times while permitting 500 requests per hour.