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);
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);
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.
trackClick(options)
This method is utilized for tracking clicks.
Parameters:
options
(object): Configuration options.
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.
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.
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
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
Node SDK Compatibility with Frontend Frameworks and Libraries
The following frontend frameworks and libraries are compatible with Node SDKs and can use them seamlessly via npm:
Next.js, Nuxt.js, SvelteKit, Gatsby, Remix, RedwoodJS, Blitz.js, Astro, Eleventy (11ty), React Static, Gridsome, VuePress, Quasar Framework, Razzle, Preact CLI, NestLand, Hydrogen, Marko, Inferno, Vite, React, Vue.js, Svelte, Preact, SolidJS, Alpine.js, Lit, Stencil.js, Hyperapp, Riot.js, Mithril.js
Last updated
Was this helpful?