npm-sca-partner

--

Usage no npm install needed!

<script type="module">
  import npmScaPartner from 'https://cdn.skypack.dev/npm-sca-partner';
</script>

README

NPM SCA Affiliate Partner

System requirements

  • Node.js 4.x || 6.x
  • Npm 3.x

How it works

Scalable works with a number of affiliate marketing partners and distributor partners to help drive traffic our site. These partners use a variety of techniques include UTM parameters and domain cookies to register when a visitor has been lead to our site from one of their external links. This module provides an interface to capture and report information on potential leads as well as trigger tracking lead events back to each partner (storing just the last one of them).

UTM parameters

Used by: Affili.net, FinanceAds and VR Dachau

The UTM query parameters utm_source, utm_medium and utm_campaign, which store information about the partner name and lead reference id are passed in external links back to our site. In order for a lead to be attributed correctly, the partners rely on us to capture and store the UTM information, and then trigger tracking immediately after specific lead events (eg. newsletter sign up) have occurred.

Our implementation of capturing these potential leads involves storing the partner information from the UTM parameters as a JSON string in a cookie, which expires in 30 (or in the case of VR Dachau, 60, or in the case of SIEMENS/BLACKROCK, 10000) days. If the visitor signs up for our newsletter before the cookie expires, we trigger the appropriate lead tracking method via inserting a tracking pixel, which in turn triggers a request with the appropriate parameters back to the affiliate partner.

Domain cookie

Used by: Optimise Media

When a visitor is directed to our site from an external link via Optimise Media (OM), OM stores a cookie on their domain. We then trigger tracking (also via tracking pixel) immediately after that visitors has signed up for our newsletter, started onboarding and/or converted to become a client.

In the lead/sale tracking event request, OM validates the lead by checking if the visitor has their previously set domain cookie in their browser. This means that we must send this tracking event blindly for every potential lead event and rely on OM to assign the lead if appropriate.

Usage

getPartnerDataFromCookie()

Returns a serialized JSON with the affiliate partner details stored on Cookie.

{
    parnterType: {string},              // one of "AFFILINET", "FINANCE_ADS", "VR_DACHAU", "BLACKROCK", "SIEMENS", "LATUS"
    partnerReferenceToken: {string},    // reference id of the partner-placed external link/ad
    partnerOrderId" {string}                   // order id of the partner
}

getPartnerDataFromQuery()

Returns a serialized JSON with the affiliate partner details that is on URL.

{
    parnterType: {string},              // one of "AFFILINET", "FINANCE_ADS", "VR_DACHAU"
    partnerReferenceToken: {string},    // reference id of the partner-placed external link/ad
}

(partnerOrderId is not extracted from the query)


savePartnerData({partnerType, partnerReferenceToken, partnerOrderId})

Stores the partner information as a JSON string in the SCA_partner cookie.


getCookieName()

Returns the name where the cookie is stored on.

SCA_partner

trackGenericPartnerLead()

Inserts an tracking pixel to trigger a lead event from the partner details stored in the SCA_partner cookie (if any). The initiated request should resemble:

Affili.net

GET https://partners.webmasterplan.com/TrackOrder.aspx?site=14898&event=lead&net_price=2&order_id=ORDER_ID&rate_number=1&publisher_id=PUBLISHER_ID

FinanceAds

GET https://www.financeads.net/tl.php?p=1428&oid=ORDER_ID&ocategory=newsletter&s_id=S_ID

NOTE: for VR Dachau, no lead is tracked. Instead, the partner reference is attached to the visitor when he/she starts onboarding.

Parameters

leadType

A String indicating the type of lead. Value must be one of "newsletter", "onboardingStart" or "sale". The initiated request should resemble:

  1. newsletter
    GET https://track.omguk.com?APPID=APP_ID&MID=1060397&PID=30688
    
  2. onboardingStart
    GET https://track.omguk.com?APPID=APP_ID&MID=1060397&PID=30688&action=Start
    
  3. sale
    GET https://track.omguk.com?APPID=APP_ID&MID=1060397&PID=30688&ex1=GIA
    
data

An plain Object containing relevant lead information.

data.emailHash

The hashed email address String of the visitor to be tracked.

data.product

In the event of a client conversion, the product String ("GIA", "ISA" etc.) should be included.

Development

Install dependencies

  • Ensure your OS has Node v(4.x || 6.x) installed
  • From the project's root dir, run npm install to install all dependencies

NPM scripts

  • Start demo at http://localhost:8087: npm start
  • Run tests (mocha):
    • junit reporter: npm test
    • command line interface: npm run test-cli
  • Build and transpile code to ES5 and save to ./lib: npm run build
  • Run code quality (eslint):
    • checkstyle reporter: npm run eslint
    • command line interface: npm run eslint-cli