Mobile SDK: Constructing batch requests
The Parsely pixel server accepts GET requests containing the information for single events. For mobile devices, sending one request per event wastes battery. The Parsely SDK sends batches of events to a proxy server, which then splits the batches into individual requests for consumption by the pixel server. The Parsely SDK creates this batched request for you, but there are some cases where you might want to construct this batched request yourself.
Please note, we do not currently accept conversions actions through the Mobileproxy.
Elements of a Mobileproxy request
Event Schema
Key | Description | Required | Valid Type(s) | Example |
---|---|---|---|---|
ts | The UNIX timestamp of the event (milliseconds since epoch) | Yes | Integer | "ts": 1363796913220884 |
url | The URL of the tracked post | Yes | String | "url": "https://samplesite.com/2021/02/03/story/" |
urlref | The referring URL | No | String | "urlref": "https://samplesite.com/" |
idsite | Parsely idsite (also refered to as apikey) | Yes | String | "idsite": "samplesite.com" |
action | The type of action (pageview, heartbeat, videostart, vheartbeat, custom) | Yes | String | "action": "pageview" |
data | A JSON object containing the parsely_site_uuid (a UUID for the current device) and any non-PII custom data. | Yes | JSON object | "data": {"parsely_site_uuid": "77e4c8f0afeb4e7643f5089235779937d9637b55", "custom_key": "custom_value"} |
sid | Session ID, an incrementing count of sessions for this user/device | No | Integer | "sid": 1 |
sts | Session Timestamp, UNIX timestamp of the session creation (milliseconds since epoch) | No | Integer | "sts": 1363796913220884 |
surl | Session Initial URL, first pageview of the session | No | String | "surl": "https://samplesite.com/2021/02/03/story/" |
sref | Session Initial Referrer, referrer of the first pageview of the session | No | String | "sref": "https://samplesite.com/" |
slts | Last Session Timestamp, UNIX timestamp of the last session the user had. 0 if this is the user’s first session | No | Integer | "slts": 1363796913220884 |
metadata | Metadata, See metadata schema | No | JSON object | See metadata schema |
inc | Engaged Time incremental value (seconds) | Only for heartbeats and vheartbeats | Integer | "inc": 5 |
tt | Engaged Time total time (milliseconds) | Only for heartbeats and vheartbeats | Integer | "tt": 15555 |
plid | Pageload id, a unique id (random integer) used for correlating events across a tracker instance. All events sent during a tracker instance should have the same Pageload id | Yes | Integer | "plid": 89273498733423634 |
pvid | Pageview ID, a unique id (random integer) used for correlating events across a pageview. Should be generated prior to sending a pageview. The pageview and all events sent before the next pageview should have a consistent Pageview ID. | Yes | Integer | "pvid": 90458904597945947 |
vsid | Videostart ID, a unique id (random integer) used for correlating events across a video play. Should be generated prior to sending a videostart. The videostart and all vheartbeats tied to the video should have a consistent Videostart ID. | Only for video related actions | Integer | "vsid": 90840938038420983 |
Metadata Schema
Key | Description | Required | Valid Type(s) | Example |
---|---|---|---|---|
canonical_url | A post’s canonical url. | No | String | "canonical_url": "https://samplesite.com/2021/02/03/story/" |
pub_date | Date this piece of content was published. (ISO 8601) | No | String | "pub_date": "2021-02-03T21:27:36.477Z" |
title | Title of the content. | No | String | "title": "Title of Article" |
authors | Up to 10 authors are accepted. | No | Array of Strings | "authors": ["John Smith", "Jane Smith"] |
image_url | URL for the main image for this post. | No | String | "image_url": "https://samplesite.comhttps://www.parse.ly/images/image_1.png" |
section | Section of the website the content appears in. | No | String | "section": "News" |
tags | Up to 20 tags on an event are allowed. | No | Array of Strings | "tags": ["Breaking", "Crime", "Toronto"] |
duration | Durations passed explicitly to trackVideoStart take precedence over any in metadata. | No | Integer | "duration": 600 |
JSON Payload Example
The body of the POST request to Mobileproxy should be a JSON object with a single key, events
, that is an array of JSON objects that conform to the Event Schema. These can optionally contain a key of metadata
. The value of metadata
should be a JSON object that conforms to the Metadata schema. The Parsely SDKs sends a batch of events every 60 seconds or when the app is backgrounded to limit the number of events sent in one request.
{
"events": [
{
"ts": 1363796913220884,
"url": "https://samplesite.com/2021/02/03/story/",
"urlref": "https://samplesite.com/",
"idsite": "samplesite.com",
"action": "pageview",
"sid": 0,
"data": {
"parsely_site_uuid": "76e4c8f0afeb4e7643f5089235779937d9637b55"
},
"sts": 1363796913220884,
"surl": "https://samplesite.com/2021/02/03/story/", "sref": "https://samplesite.com/",
"slts": 1363796913220884,
"metadata": {
"canonical_url": "https://samplesite.com/2021/02/03/story/",
"pub_date": "2021-02-03T21:27:36.477Z",
"title": "Title of Article",
"authors": ["John Smith", "Jane Smith"],
"image_url": "https://samplesite.comhttps://www.parse.ly/images/image_1.png",
"section": "News",
"tags": ["Breaking", "Crime", "Toronto"]
},
"plid": 89273498733423634,
"pvid": 90458904597945947
},
{
"ts": 1363796913226884,
"url": "https://samplesite.com/2021/02/03/story1/",
"urlref": "https://samplesite.com/2021/02/03/story/",
"idsite": "samplesite.com",
"action": "pageview",
"data": {
"parsely_site_uuid": "76e4c8f0afeb4e7643f5089235779937d9637b55"
},
"sid": 0,
"sts": 1363796913220884,
"surl": "https://samplesite.com/2021/02/03/story/", "sref": "https://samplesite.com/",
"slts": 1363796913220884,
"plid": 89273498733423634,
"pvid": 90384029834793984
},
{
"ts": 1363796913229884,
"url": "https://samplesite.com/2021/02/03/story1/",
"urlref": "https://samplesite.com/2021/02/03/story/",
"idsite": "samplesite.com",
"action": "heartbeat",
"data": {
"parsely_site_uuid": "76e4c8f0afeb4e7643f5089235779937d9637b55"
},
"sid": 0,
"sts": 1363796913220884,
"surl": "https://samplesite.com/2021/02/03/story/", "sref": "https://samplesite.com/",
"slts": 1363796913220884,
"plid": 89273498733423634,
"pvid": 90384029834793984,
"tt": 643343,
"inc": 10
}
]
}
Request Specifications
Requests made to MobileProxy should be POST requests with a Content-Type
header of application/json; charset=utf-8
. Our mobile SDKs generate a user-agent header from the application name, application version, operating system name, operating system version, and architecture. You should follow a similar format for your header so that the traffic is properly categorized. The request body should be a serialized JSON object like the example above.
Key | Description | Required | Valid Type(s) | Example |
---|---|---|---|---|
Url | The URL to send the request to | Yes | String | https://p1.parsely.com/mobileproxy |
User-Agent | User-Agent Header | Yes | String | com.Parsely.Parsely/2.2.3 iOS/13.3 (x86_64) |
Content-Type | Content-Type Header | Yes | String | application/json; charset=utf-8 |
Body | Body of the request | Yes | String | See above example |
An example curl request:
curl -X "POST" "https://p1.parsely.com/mobileproxy" -H 'User-Agent: com.Parsely.Parsely/2.2.3 iOS/13.3 (x86_64)' -H 'Content-Type: application/json; charset=utf-8' -d
{
"events": [
{
"ts": 1363796913220884,
"url": "https://samplesite.com/2021/02/03/story/",
"urlref": "https://samplesite.com/",
"idsite": "samplesite.com",
"action": "pageview",
"sid": 0,
"data": {
"parsely_site_uuid": "76e4c8f0afeb4e7643f5089235779937d9637b55"
},
"sts": 1363796913220884,
"surl": "https://samplesite.com/2021/02/03/story/", "sref": "https://samplesite.com/",
"slts": 1363796913220884,
"metadata": {
"canonical_url": "https://samplesite.com/2021/02/03/story/",
"pub_date": "2021-02-03T21:27:36.477Z",
"title": "Title of Article",
"authors": ["John Smith", "Jane Smith"],
"image_url": "https://samplesite.comhttps://www.parse.ly/images/image_1.png",
"section": "News",
"tags": ["Breaking", "Crime", "Toronto"]
},
"plid": 89273498733423634,
"pvid": 90458904597945947
},
{
"ts": 1363796913226884,
"url": "https://samplesite.com/2021/02/03/story1/",
"urlref": "https://samplesite.com/2021/02/03/story/",
"idsite": "samplesite.com",
"action": "pageview",
"data": {
"parsely_site_uuid": "76e4c8f0afeb4e7643f5089235779937d9637b55"
},
"sid": 0,
"sts": 1363796913220884,
"surl": "https://samplesite.com/2021/02/03/story/", "sref": "https://samplesite.com/",
"slts": 1363796913220884,
"plid": 89273498733423634,
"pvid": 90384029834793984
},
{
"ts": 1363796913229884,
"url": "https://samplesite.com/2021/02/03/story1/",
"urlref": "https://samplesite.com/2021/02/03/story/",
"idsite": "samplesite.com",
"action": "heartbeat",
"data": {
"parsely_site_uuid": "76e4c8f0afeb4e7643f5089235779937d9637b55"
},
"sid": 0,
"sts": 1363796913220884,
"surl": "https://samplesite.com/2021/02/03/story/", "sref": "https://samplesite.com/",
"slts": 1363796913220884,
"plid": 89273498733423634,
"pvid": 90384029834793984,
"tt": 644545,
"inc": 10
}
]
}'
Last updated: December 02, 2022