Skip to content

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

KeyDescriptionRequiredValid Type(s)Example
tsThe UNIX timestamp of the event (milliseconds since epoch)YesInteger"ts": 1363796913220884
urlThe URL of the tracked postYesString"url": "https://samplesite.com/2021/02/03/story/"
urlrefThe referring URLNoString"urlref": "https://samplesite.com/"
idsiteParsely idsite (also refered to as apikey)YesString"idsite": "samplesite.com"
actionThe type of action (pageview, heartbeat, videostart, vheartbeat, custom)YesString"action": "pageview"
dataA JSON object containing the parsely_site_uuid (a UUID for the current device) and any custom data that does not convey personal information.YesJSON object"data": {"parsely_site_uuid": "77e4c8f0afeb4e7643f5089235779937d9637b55", "custom_key": "custom_value"}
sidSession ID, an incrementing count of sessions for this user/deviceNoInteger"sid": 1
stsSession Timestamp, UNIX timestamp of the session creation (milliseconds since epoch)NoInteger"sts": 1363796913220884
surlSession Initial URL, first pageview of the sessionNoString"surl": "https://samplesite.com/2021/02/03/story/"
srefSession Initial Referrer, referrer of the first pageview of the sessionNoString"sref": "https://samplesite.com/"
sltsLast Session Timestamp, UNIX timestamp of the last session the user had. 0 if this is the user’s first sessionNoInteger"slts": 1363796913220884
metadataMetadata, See metadata schemaNoJSON objectSee metadata schema
incEngaged Time incremental value (seconds)Only for heartbeats and vheartbeatsInteger"inc": 5
ttEngaged Time total time (milliseconds)Only for heartbeats and vheartbeatsInteger"tt": 15555
plidPageload 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 idYesInteger"plid": 89273498733423634
pvidPageview 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.YesInteger"pvid": 90458904597945947
vsidVideostart 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 actionsInteger"vsid": 90840938038420983

Metadata Schema

KeyDescriptionRequiredValid Type(s)Example
canonical_urlA post’s canonical url.NoString"canonical_url": "https://samplesite.com/2021/02/03/story/"
pub_dateDate this piece of content was published. (ISO 8601)NoString"pub_date": "2021-02-03T21:27:36.477Z"
titleTitle of the content.NoString"title": "Title of Article"
authorsUp to 10 authors are accepted.NoArray of Strings"authors": ["John Smith", "Jane Smith"]
image_urlURL for the main image for this post.NoString"image_url": "https://samplesite.comhttps://www.parse.ly/images/image_1.png"
sectionSection of the website the content appears in.NoString"section": "News"
tagsUp to 20 tags on an event are allowed.NoArray of Strings"tags": ["Breaking", "Crime", "Toronto"]
durationDurations passed explicitly to trackVideoStart take precedence over any in metadata.NoInteger"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.

KeyDescriptionRequiredValid Type(s)Example
UrlThe URL to send the request toYesStringhttps://p1.parsely.com/mobileproxy
User-AgentUser-Agent HeaderYesStringcom.Parsely.Parsely/2.2.3 iOS/13.3 (x86_64)
Content-TypeContent-Type HeaderYesStringapplication/json; charset=utf-8
BodyBody of the requestYesStringSee 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 11, 2023