1. Assign io-subscription-block class to the site element where user can subscribe. 

2. Assign io-subscription-button class to the buttons that lead to the subscription page. 

3. Push user_status parameter to _io_config on every page. Choose one of the following values:

  • free_unreg - free non-registered user
  • free_reg - free registered user
  • trial - trial user
  • paid - paid subscription user

Only these four values are available.

4. Fire “Subscription_trial” event through push.onthe.io once user registers for the trial.

You can do it by submitting a POST request using https://push.onthe.io/?token={PROJECT_HASH} with the following fields:

'data' => [
'event' => 'subscription_trial', //event name
'url' => '/url-of-a-publication', //Article URL that preceded the subscription (value from cookie __io_subscription_url)
'source' => 'facebook' // Referrer for this session]

where
url’ is the url of the article from which user made the subscription; it’s located in _io_subscription_url COOKIE
source’ is the user’s referrer during this session, is located in _io_subscription_source COOKIE

Cookies are saved after the click on io-subscription-button

PHP Example:

<?php

function httpPost($url, $data)
{
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($curl);
    curl_close($curl);
   
    return $response;
}

$url = 'https://push.onthe.io/?token={PROJECT_HASH}';
$data = [
    'data' => [
    'event' => 'subscription_trial',
    'url' => '/url-of-a-publication',
    'source' => 'facebook'
    ]
];
print_r(httpPost($url, $data));

6. Fire “Subscription_success” event through push.onthe.io once user activates the subscription.

It is done by submitting a POST request using https://push.onthe.io/?token={PROJECT_HASH} with the following fields:

'data' => [
'event' => 'subscription_success', //event name
'url' => '/url-of-a-publication', //Article URL that preceded the subscription (value from cookie __io_subscription_url)
'source' => 'facebook', // Referrer for this session    
'coins_int' => 1000, // order total in cents (1$ = 100, 10$ = 1000)
'previous_user_status' => 'free_unreg', // user status before purchase
'new_user_status' => 'paid', // user status after purchase

]

url’ is the url of the article from which user made the subscription; it’s located in _io_subscription_url COOKIE
source’ is the user’s referrer during this session, is located in _io_subscription_source COOKIE
'
coins_int' - is the subscription price in cents
'
previous_user_status' - status of the user before he made the payment (for example, 'free_unreg').
'
new_user_status' - status of this user after he made the payment (for example, 'paid').

 Cookies are saved upon clicking on io-subscription-button

PHP Example:

<?php

function httpPost($url, $data)
{
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($curl);
    curl_close($curl);
    return $response;
}

$url = 'https://push.onthe.io/?token={PROJECT_HASH}';
$data = [
'data' => [
    'event' => 'subscription_success',
    'url' => '/url-of-a-publication',
    'source' => 'facebook',
    'coins_int' => 10000,
    'previous_user_status' => 'free_unreg',
    'new_user_status' => 'paid',    
    ]
];

print_r(httpPost($url, $data));
Did this answer your question?