You need to include this JS-code into a page to track pageview data from your website:
Articles Tracking
To send us data about the article please do the following:
Add the javascript-code to all the Article pages:
Add this class to the text block: io-article-body.
For example:
Article text
or add class io-article-body to existen class of an article:
Article text
Important: By default we track the article by URL in the address line. If one article can be available by more than 1 URL, please do the following:
add to _io_data_config a url field with a value of canonical URL of the article.
For example:
This is necessary to track one article as one item in the dashboard.
Articles’ titles
By default we track the title of the article from tag of the website page.
If you want to track some other title please set it statically or dynamically in a following way:
_io_data_config.page = ‘Article title’;
or
_io_data_config.page = variable.from.your.cms;
Authors and Categories (Sections)
You can set author and section statically or dynamically in a following way:
If you don't want to indicate the real author's name, you may put ID instead, and use JSON file to send us the list of authors hidden behind the IDs.
Link to JSON file should be sent to your Customer Success Manager or io.support@onthe.io
Mobile version of the site
To track mobile version please add the same config as you did for the desktop. Important: URL has to be the same in _io_data_config on mobile and desktop.
Application tracking
Sending data is as simple as sending simple HTTPS GET requests.
Param pageviews we call a metric, and page and category are slices.
Slices values sent to the t system should not contain commas ( , ) or colons ( : ). Commas and colons should be replaced by #44; and #58; accordingly.
All values in slices should be URL-encoded and have UTF-8 encoding.
Slices *Required slices
Slice
Description
Example
page*
Article title
Breaking news#58; Project General has been connected to io analytics system
article_type
Type of an article
paid
category
Article category (or section)
SPORT
sub_category
Article subcategory (or subsection)
FOOTBALL
author
Article author. If page is article or news, slice author is required
John Doe
previous_page
Previous page title, from which the user came. If there is no such a page - this slice should be omitted;
If user came from the main page - the value of this slice will be Main Page
Breaking news#58; Project General wants to be connected to io analytics system
platform
Platform of the app
iOS
referrer
Referrer
It's required to set referrer value to app for application
domain
Domain
{hostname}
url
Article pathname
/some/article/url
Pageviews
pageviews metric should be sent when the user opens an article.
Read finished
read_finished metric should be sent if user read the article to the end.
Uniques
uniques metric should be sent only if user opened the app for the first time during 24 hours.
Visits
visits metric should be sent not earlier than 15 minutes after the end of the user session.
Time
Metric time This metric should be sent every 10 seconds after the user opened an article. This metric shows how much time did the user spend on a page.
This metric should contain only one slice - page.
News blocks
.io can track data from some page blocks and also show CTR of this block and share of viewers.
To do this you must take a few steps:
Step 1.
Put attribute data-vr-zone with a name of block you want to track.
Step 2.
Put attribute data-vr-contentbox with a position name of this link in block.
If you don't want to show your authors or categories on a page but you have an id of the authors and you want to track these data you need to include this HTML-code:
And you need to contact with your .io manager and give him an url to authors list.
Example of list in JSON:
Following from FB Group
If you want to track links from your facebook group you need to include label ?f in post's link
AJAX
If you have endless scroll please do the following for each content refresh:
set new url and page in _io_data_config. For example:
_io_data_config.url = ‘/canonical-url-of-loaded-article/’;
_io_data_config.page = ‘Title of loaded article’;
add new author and category for each article. In case you do not do this - each article will have the same author and category as the first one had.
For example:
Important: each article loaded by AJAX should have html-class io-article-body.
Google AMP
If you want to track data from Google AMP pages you need to insert code below to your website:
Into tag <head>:
Into tag <body>:
Facebook Instant Articles
If you want to track data from Facebook Instant Articles pages you need to insert code below to your Instant Articles page in <body> block without any additional elements in the header or footer blocks:
Youtube tracking
To be able to track Youtube embedded videos on a website we use Youtube's API. It requires to use additional parameters in 'src' attribute of iframe when embedding video to the page.
Those parameters are `enablejsapi` and `origin`.
`enablejsapi` pararameter must be allways set to 1. `origin` parameter must match your site's origin.
For example, we are trying to embed video bellow to our article
To do this we are using code like this :
To give IO's code availability to track this video we need to change this:
If you don't want to modify all video content on your website we can do it dynamically. Our code can modify your Youtube iframe's src before it loads so this procedure will look absolutelly seamless to your website's visitors
API
Basics
You could get data from API by sending POST-requests to:
https://api.onthe.io/{hash}
with such parameters:
{
"key" : "{api_key}",
"entities" : "{list of entities or a single entity}",
"options" : "{set-options-here}"
}
Key
Secret key, whis is generated for your project. Do not share your hash/key pair with others.
Entities
An array of parameters you want to get could contain multiple number of entities to select.