Node SDK

This Node.js SDK is designed to track user interactions, such as clicks, impressions, conversions and other events, on your web applications

Get started

To start tracking using Offer18's Node SDK, you'll need to integrate the SDK into your web application as a node module.

Find out latest stable version of Node Package


Installation

You can install the package using npm:

npm install offer18-sdk

or

npm i offer18-sdk


Usage

Import

import Offer18SDK from 'offer18-sdk';

Initialize

const Offer18WebSDK = new Offer18SDK();

Available Methods

// Initialize Conversion
Offer18WebSDK.initializeConversion('YOUR-CLICK-ID-PARAMETER');

// Register Click
Offer18WebSDK.trackClick(options);

// Register Impression
Offer18WebSDK.trackImpression(options);

// Register Conversion
Offer18WebSDK.trackConversion(options);

// Reset Cookies
Offer18WebSDK.clearCookies();

// Enable Logger
Offer18WebSDK.activateDebugMode();


Conversion flow

The conversion flow is the sequence in which only conversions will be tracked by the Node SDK. To implement the conversion flow, After initializing the SDK, you need to add methods in the following order::

Placement : Page load or after the component mounts

Offer18WebSDK.initializeConversion('YOUR-CLICK-ID-PARAMETER');

then

Placement : Thank you Page/Order Success Page

Offer18WebSDK.trackConversion(options);

Know more about YOUR-CLICK-ID-PARAMETER & options in Method Overview


SDK flow

The SDK flow is the sequence that allows users to track the entire conversion process in the Node SDK, including tracking impressions, clicks, and conversions. After initializing the SDK, you need to add methods in the following order:

Placement : Page load or after the component mounts

Offer18WebSDK.trackImpression(options)

then

Placement: Can be placed on all pages (on page load or after the component mounts)

Offer18WebSDK.trackClick(options);

then

Placement : Thank you Page/Order Success Page

Offer18WebSDK.trackConversion(options);

Know more about options in Method Overview


Method Overview

initializeConversion('YOUR-CLICK-ID-PARAMETER')

This method is used to initialize the conversion. You need to add this method either on page load or after the component mounts.

Replace YOUR-CLICK-ID-PARAMETER with the parameter key that is used to accept the value from the {tid} token in the offer URL.

trackClick(options)

This method is utilized for tracking clicks.

  • Parameters:

    • options (object): Configuration options.

ParameterTypeDescription

trackingURL

string

Mandatory: Tracking URL which can be extracted from Offer18 dashboard

keymapping

array

An array of Offer18 parameters and Native parameters in the format <OFFER18-PARAMETER>:<YOUR-PARAMETER>. User can replace <OFFER18-PARAMETER> with Offer18 Parameters like aff_sub1, aff_sub2 and <YOUR-PARAMETER> with their parameters in which user is getting values from their network.

Example code

Offer18WebSDK.trackClick({
    trackingURL: 'https://example.o18.click/c?o=0000000&m=0000',
    keymapping: ['a:<YOUR-PARAMETER>']
});

trackImpression(options)

This method is utilized for tracking impressions.

  • Parameters:

    • options (object): Configuration options.

ParameterTypeDescription

impressionURL

string

Mandatory: Tracking URL which can be extracted from Offer18 dashboard

keymapping

array

An array of Offer18 parameters and Native parameters in the format <OFFER18-PARAMETER>:<YOUR-PARAMETER>. User can replace <OFFER18-PARAMETER> with Offer18 Parameters like aff_sub1, aff_sub2 and <YOUR-PARAMETER> with their parameters in which user is getting values from their network.

Example code

Offer18WebSDK.trackImpression({
    impressionURL: 'https://example.o18.click/i?o=0000000&m=0000',
    keymapping: ['a:<YOUR-PARAMETER>']
});

trackConversion(options)

This method is utilized for tracking conversions.

  • Parameters:

    • options (object): Configuration options.

ParameterTypeDescription

domain

string

Mandatory: Postback domain of the user.

accountId

string

Mandatory: Offer18 account id of the user.

offerId

string

Mandatory: Id of the campaign.

coupon

string

Coupon code can be used here.

postbackType

string

It can be either 'iframe' or 'pixel', default value is 'iframe'.

isGlobalPixel

boolean

User can configure global pixel by setting this true, default value is false.

allowMultiConversion

boolean

User can allow MultiConversion by setting this true, default value is false.

conversionData

object

This object contains the parameters which can be used to get values from the network.

conversionData Object

ParameterTypeDescription

event

string

Event Name (Please specify the event)

payout

string

Payout Amount (Please specify the payout amount)

sale

string

Sale Amount (Please specify the sale amount)

currency

string

Currency code

adv_sub1

string

Advertiser sub parameter 1

adv_sub2

string

Advertiser sub parameter 2

adv_sub3

string

Advertiser sub parameter 3

adv_sub4

string

Advertiser sub parameter 4

adv_sub5

string

Advertiser sub parameter 5

Example code

Offer18WebSDK.trackConversion({
        domain: '',
        accountId: '',
        offerId: '',
        coupon:'',
        postbackType: '', // 'iframe' or 'pixel'
        isGlobalPixel: false, // true or false
        allowMultiConversion: false, // true or false
        conversionData: {
            event: '', // Event Name (Please specify the event)
            payout: '', // Payout Amount (Please specify the payout amount)
            sale: '', // Sale Amount (Please specify the sale amount)
            currency: '',
            adv_sub1: '',
            adv_sub2: '',
            adv_sub3: '',
            adv_sub4: '',
            adv_sub5: '',
        }
    });

clearCookies()

This method is utilized for removing all first-party cookies added by this package.

activateDebugMode()

This method is utilized for enabling the logger. Logs of every action performed by this package will be visible in the browser's developer tools console. You need to add this method immediately after initializing the SDK

Last updated