Instructions for custom implementation of tracking the mobile app traffic
- Page View request
- Article Read request
- Attention Time request
- Android request example
- iOS request example
This is usually the last stage of the implementation so, at this moment, the Insights tracking script probably already sends the data from the website. You can check these events in the Network tab, filtered by this regular expression string:
/ingestion.smartocto|contentinsights.com/
The expected response for all GET requests is "204 No Content".
All events are sent to the following endpoints:
https://ingestion.smartocto.com/p
https://ingestion.smartocto.com/a
The legacy domain is contentinsights.com and it's also functional:
https://ingestion.contentinsights.com/p
https://ingestion.contentinsights.com/a
As you can see, there are two types of requests sent by the Insights tracking script:
- p-request
- a-request
Here is a detailed explanation of each.
1. Page View and Article Read
The Page View request should be fired immediately after the Insights script has been triggered.
On a regular website (JavaScript) implementation, the smartocto Insights tracker waits for 10 seconds after the page has been loaded and then fires the Article Read request, if the visitor is still on the page.
1.1. Page View request
This request is sent in the form of a GET request for the image on our servers. The endpoint URL is:
https://ingestion.contentinsights.com/p
Here is the list of all parameters that can be sent in a single Page View request (p-request):
a - comma-separated list of authors
b - referral URL
c - article title
d - article URL
e - comma-separated list of sections (categories)
f - domain ID
g - article publish date in extended ISO 8601 format (2020-02-20T12:34:56+00:00)
h - comma-separated list of tags [optional]
i - comments [deprecated]
j - access level: "free" or "paid" [optional]
k - article type [optional]
l - image URL [deprecated]
m - reader type: "anonymous", "registered" or "subscribed" [optional]
n - page type: "article" (default value) or "landing" [optional]
pid - unique article ID (usually the ID from the internal CMS)
u - session cookie identifier
ul - lifetime cookie identifier
x - request identifier (random number)
t - request type identifier (t=0)
ver - version indicator, automatically assigned by the tracker
err - error code, automatically assigned
ch - "Android" or "iOS"
os_ver - only from mobile SDK requests (system version)
manuf - only from mobile SDK requests (device manufacturer)
On regular website implementations, we can see some legacy parameters with empty values that are automatically added by the tracker. They are not sent through the mobile SDKs, AMP and FIA requests and can be completely omitted in custom implementations.
Optional parameters can also be omitted, but please consult our Support Team for details and special cases (e.g. Paywall setup).
Please note that mobile SDK and custom-built app requests don't have to contain all parameters. For any custom implementation, here is the minimum set of parameters to make a valid p-request:
d - URL
f - domain ID
pid - unique article ID (can be canonical URL or the ID from internal CMS)
u - session cookie identifier
ul - lifetime cookie identifier
x - request identifier (random number)
t - request type identifier (t=0)
ch - AMP, Android or iOS
This is because for a given article the system normally receives standard requests from the website and those requests contain all meta-data.
Mobile app or custom-built requests can have a reduced number of parameters because the system will process the data and attribute the statistics to the corresponding article by matching the URL (d), domain ID (f), and unique article ID (pid).
However, if for any reason mobile app content can't be found on the website (e.g. specially promoted or premium content), additional parameters must be set (title, authors, pubdate, sections, etc) because the system will not have any other source to match. Please refer to the examples section at the bottom of this page.
Cookie values
There are two cookies added by the Insights tracker on standard website implementations:
u - a session cookie (identifier) that lasts for 30 minutes.
ul - a lifetime cookie that expires two years after the last visit.
In the original JavaScript tracker code, the session cookie is generated like this:
_ain.generateCID = function() {
return new Date().getTime() + "." + Math.random() * 1e9;
};
So, the lifetime cookie can be set to two years ahead with this formula:
ul = new Date().getTime() + 1000*60*60*24*365*2 + "." + Math.random() * 1e9;
On websites running the Insights script, these values can be found in the browser cookies with their corresponding values:
_ain_cid = u = 1701861234000.128094919.29444183
_ain_uid = ul = 1765019634000.319545495.82194793
If the value of the ul format doesn't correspond with the abovementioned, the system will parse it with the timestamp of the received request.
x parameter
The x-parameter is a random number whose main purpose is to prevent caching, but all p- and a-requests should have the same x value during a single article visit from a single visitor.
JavaScript example:
x = Math.random(); // 0.10776367005369303
It is possible to only track pageviews which significantly simplifies the development process, as only one p-request should be sent with each visit.
1.2. Article Read request
This request is sent to the same address as the Page View request with the same parameters and one important difference (t=1):
d - URL
f - domain ID
pid - unique article ID (can be canonical URL or the ID from internal CMS)
u - session cookie identifier
ul - lifetime cookie identifier
x - request identifier (random number)
t - request type identifier (t=1)
ch - AMP, Android or iOS
word count
It is possible to send some additional and optional parameters.
For example it's possible to send the word count, as this value can't be automatically detected, as the JavaScript tracker does on a regular setup on the website.
wc - the number of words in the article, including the title and the description
2. Attention time tracking
After the page is loaded, the code starts tracking active attention time. Active time means there is a person behind the screen whom we detect the help of tab focus and page activity (e.g. mouse movements, keyboard clicks, scrolling, etc.)
Attention Time request
The tracking is done by sending one Attention Time request every 5 seconds to smartocto Insights’ servers via GET parameters. The address is:
https://ingestion.smartocto.com/a
Here is the list of all parameters that can be sent in a single Attention Time request (a-request):
d - URL
f - domain ID
pid - article ID
b - referrer
ch - (values: AMP, Android or iOS)
u - session cookie
ul - lifetime cookie
at - current attention time, accumulated
ar - a difference in seconds between the two consecutive requests
sp - scroll position, considering only the article's true content
ts - current timestamp
seq - sequence number, the request counter for the current page visit
x - request identifier
Please note that matching parameters from a-request should have the same value as a corresponding p-request parameter for a given article in a single page load.
Example:
f - domain ID
d - URL
b - referrer
pid - article ID
ch - channel identifier ("Android" or "iOS")
x - request identifier (random number)
u - session cookie
ul - lifetime cookie
Scroll Position calculation
Here's an example of how the scroll position could be calculated (the result should be in percentages, 0-100):
sp = 100 * (viewportHeight + scrollTop) / scrollHeight
Request examples
Here are a few example requests from a single session (on a single article):
Android requests
The following parameters were sent through the tracker:
f=2500
d=https%3A%2F%smartocto.com%2Fblog%2Foptimising-story-performance-right-editorial-data
pid=article-12345
u=1626394354.158210474
ul=1621899131.186346184
x=123456789
ch=Android
ver=5
os_ver=29
manuf=OnePlus
Page View - fires immediately after opening an article (0 seconds):
p0: https://ingestion.contentinsights.com/p?ver=5&os_ver=29&d=https%3A%2F%smartocto.com%2Fblog%2Foptimising-story-performance-right-editorial-data&t=0&u=1626394354.158210474&ch=Android&f=2500&manuf=OnePlus&ul=1621899131.186346184&x=123456789&pid=article-12345
Article Read - fires if the user reads an article for 10 seconds:
p1: https://ingestion.contentinsights.com/p?ver=5&os_ver=29&d=https%3A%2F%smartocto.com%2Fblog%2Foptimising-story-performance-right-editorial-data&ch=Android&f=2500&manuf=OnePlus&pid=article-12345&wc=0&t=1&u=1626394354.158210474&ul=1621899131.186346184&x=123456789
Attention Time - fires every 5 seconds when the user reads an article:
a1: https://ingestion.contentinsights.com/a?ver=5&os_ver=29&d=https%3A%2F%smartocto.com%2Fblog%2Foptimising-story-performance-right-editorial-data&ch=Android&f=2500&manuf=OnePlus&pid=article-12345&ar=5&at=5&u=1626394354.158210474&ul=1621899131.186346184&x=123456789&sp=30&seq=1&ts=1626394359
a2: https://ingestion.contentinsights.com/a?ver=5&os_ver=29&d=https%3A%2F%smartocto.com%2Fblog%2Foptimising-story-performance-right-editorial-data&ch=Android&f=2500&manuf=OnePlus&pid=article-12345&ar=5&at=10&u=1626394354.158210474&ul=1621899131.186346184&x=123456789&sp=60&seq=2&ts=1626394364
a3: https://ingestion.contentinsights.com/a?ver=5&os_ver=29&d=https%3A%2F%smartocto.com%2Fblog%2Foptimising-story-performance-right-editorial-data&ch=Android&f=2500&manuf=OnePlus&pid=article-12345&ar=5&at=15&u=1626394354.158210474&ul=1621899131.186346184&x=123456789&sp=90&seq=3&ts=1626394369
iOS requests
f=2500
d=https%3A%2F%smartocto.com%2Fblog%2Fwhy-great-content-marketing-strategy-beats-third-party-cookies
pid=article-98765
u=1626393805877.913.104151112
ul=1623725622013.678.424238496
x=987654321
ch=iOS
ver=6.7.7
os_ver=14.4.2
manuf=Apple
p0: https://ingestion.contentinsights.com/p?d=https%3A%2F%smartocto.com%2Fblog%2Fwhy-great-content-marketing-strategy-beats-third-party-cookies&f=2500&pid=article-98765&u=1626393805877.913.104151112&ul=1623725622013.678.424238496&x=987654321&t=0&ver=6.7.7&ch=iOS&os_ver=14.4.2&manuf=Apple
p1: https://ingestion.contentinsights.com/p?d=https%3A%2F%smartocto.com%2Fblog%2Fwhy-great-content-marketing-strategy-beats-third-party-cookies&f=2500&pid=article-98765&u=1626393805877.913.104151112&ul=1623725622013.678.424238496&x=987654321&t=1&ver=6.7.7&ch=iOS&os_ver=14.4.2&manuf=Apple
a1: https://ingestion.contentinsights.com/a?d=https%3A%2F%smartocto.com%2Fblog%2Fwhy-great-content-marketing-strategy-beats-third-party-cookies&f=2500&pid=article-98765&u=1626393805877.913.104151112&ul=1623725622013.678.424238496&at=5&ar=5&sp=40&ts=1626393810&seq=1&x=987654321&ch=iOS
a2: https://ingestion.contentinsights.com/a?d=https%3A%2F%smartocto.com%2Fblog%2Fwhy-great-content-marketing-strategy-beats-third-party-cookies&f=2500&pid=article-98765&u=1626393805877.913.104151112&ul=1623725622013.678.424238496&at=10&ar=5&sp=80&ts=1626393815&seq=2&x=987654321&ch=iOS
Support
If you have any additional questions or concerns feel free to contact our Support Team.