Getting started
These pages contain information on how to use the Analytics API.
The Analytics API allows you to create analytics events, enabling the collection of usage data that is used in Partium Analytics dashboards.
Authentication
In order to be able to create events in the Analytics API an access token or API key with Find API permission needs to be used. See the authentication documentation for the different options.
To get started with an API key, go to section API Keys to create an API key for the Find API. After the API key has been created, it can be used for getting access to the Analytics API.
Creating events
All Partium Analytics events follow this common base structure:
Request body field | Value |
---|---|
event | Determines the specific event that should be created |
external_user_id | (Optional) Unique identifier of the user to allow distinguishing users for Partium Analytics |
data | Includes data structured according to the event-specific schema, as detailed on the corresponding event pages |
To create an event in the Analytics API the event specific data has to be provided in the request body (for the concrete structure and description on what kind of data to provide, see the event specific documentations).
After events are successfully created the response contains the event_id
and created_at
timestamp of the created event.
See the following example for creating an event:
- HTTP
- Python
- JavaScript
> POST https://api.partium.io/1/find/search
> Authorization: Bearer <<Your Access Token or API Key>>
> Content-Type: application/json
> Content-Length: 207
>
> {
> "event": "part_detail_enter",
> "data": {
> "partium_id": "f81d6484-a8a6-455a-8538-8ae0e88d145e",
> "search_session_id": "d595cb11-fddb-428a-be07-c4a36ac91e4f",
> "index": 1
> }
> }
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Content-Length: 93
<
< {
< "event_id": "6757e4f4-c925-4a3e-bae6-e428f52f7ba7",
< "created_at": "2024-09-04T10:55:59.004618"
< }
response = requests.post(
'https://api.partium.io/1/analytics/events',
headers={
'Authorization': 'Bearer <<Your Access Token or API Key>>',
},
json={
'event': 'part_detail_enter',
'data': {
'partium_id': 'f81d6484-a8a6-455a-8538-8ae0e88d145e',
'search_session_id': 'd595cb11-fddb-428a-be07-c4a36ac91e4f',
'index': 1
}
},
)
fetch('https://api.partium.io/1/analytics/events', {
method: 'POST',
headers: {
Authorization: 'Bearer <<Your Access Token or API Key>>',
},
body: {
event: 'part_detail_enter',
data: {
partium_id: 'f81d6484-a8a6-455a-8538-8ae0e88d145e',
search_session_id: 'd595cb11-fddb-428a-be07-c4a36ac91e4f',
index: 1
},
},
}).then(res => {
...
});
Replace <<Your Access Token or API Key>>
with the preferred authentication method. See Authentication.