Click Tracking

Tracking clicks using the Everflow SDK

The simplest way to start tracking clicks is to generate a click using the following code :

EF.click({
  offer_id: 1, // Required. The offer id
  affiliate_id: 1, //Required. The affiliate id
});

You may wish to add additional data that will be passed along with the click :

EF.click({
  offer_id: 1, // Required. The offer id
  affiliate_id: 1, //Required. The affiliate id

  uid: 5, // Optional : Offer URL Id
  creative_id: 14, // Optional : Offer Creative ID

  // Optional. Sub placement values.
  sub1: '',
  sub2: '',
  sub3: '',
  sub4: '',
  sub5: '',
  source_id: '',

  coupon_code: '...', // Optional Coupon Code at the click level

  fbclid: '...', // Facebook unique click ID
  gclid: '...', // Google unique click ID

  disable_fingerprinting: false, // Optional. Browser fingerprinting is used to enhance user tracking. Defaults to false when omitted
});

Extracting data from the URL

When working with direct linking, the affiliate id involved in the click will most likely be dynamic and the value will be passed in the query string of the URL.

The Everflow SDK provides a method to extract any value from the URL. In the following example, the script executes on a landing page where the affiliate id is passed using the affid url parameter : https://destination-url.com?affid=5

EF.click({
  offer_id: 1, // Required. The offer id
  affiliate_id: EF.urlParameter('affid'), //Required. The affiliate id
});

The EF.urlParameter can be used to extract any query string parameter from the URL. For example if the destination URL was instead : https://destination-url.com?oid=3&affid=5&src=facebook&app=mobile, you could use the following code :

EF.click({
  offer_id: EF.urlParameter('oid'), // Required. The offer id
  affiliate_id: EF.urlParameter('affid'), //Required. The affiliate id
  
  sub3: EF.urlParameter('src'), // Optional : "facebook" would be passed as the sub3 in this example
  sub4: EF.urlParameter('app'), // Optional : "mobile" would be passed as the sub4 in this example
  sub5: EF.urlParameter('ref'), // The "ref" query string parameter is missing from the URL. Nothing would be passed as the sub5

});

You can use the Everflow SDK to enhance traditional tracking when you own landing pages. In other words, you can use the Everflow SDK even if you use traditionnal redirect links, which will have the benefit of setting a first-party cookie.

In order to do so, fill the transaction_id parameter when using EF.click. Normally, you would configure your destination url to include the transaction_id, offer_id and affiliate_id macros. Given the following destination url: https://destination-url.com?transaction_id=af189e77650e4e908af797b61b03ac0b&oid=1&affid=5

EF.click({
  offer_id: EF.urlParameter('oid'), 
  affiliate_id: EF.urlParameter('affid'),
  transaction_id: EF.urlParameter('transaction_id')
});

Custom Parameters

It’s also possible to add free form parameters to the click. This is effectively equivalent to adding additional query string parameters to the tracking link URL.

EF.click({
  offer_id: EF.urlParameter('oid'), // Required. The offer id
  affiliate_id: EF.urlParameter('affid'), //Required. The affiliate id

  //Optional. Free form parameters to be appended to the click URL
  parameters: {
    "param1" : "customValue1",
    "param2" : "customValue2" 
  }
})
Attribution in Multi-Tenant Scenarios

While the Everflow SDK does support multiple accounts generating clicks on the same page, it’s important to understand that it does present its own set of challenges. The SDK relies on browser features like local storage and cookies to store the transaction IDs necessary for attribution.

The SDK was built with single-tenant usage in mind and may require a little custom work in order to attribute conversions to the right click, especially in scenarios where both networks use the same offer ID.

Please read the Domains Configuration page for more details on how to configure the SDK in such scenarios.

The following sections (“Fetching The Transaction ID” and “Extracting The Transaction ID”) should give you enough information to come up with an attribution strategy that works for your multi-tenant scenario.

Advanced Use

Fetching The Transaction ID

Clicks are identified by unique transaction IDs in Everflow. There are scenarios in which it can be useful to make use of that transaction ID immediately after generating a click.

The EF.click method returns a Promise which, when resolved, will give the transaction ID :

EF.click({
  offer_id: EF.urlParameter('oid'), 
  affiliate_id: EF.urlParameter('affid'),
})
.then((transactionId) => {
  // transactionId containts the unique Everflow transaction ID
  console.log(transactionId)
});
Extracting The Transaction ID

It’s also possible to extract the transaction ID of the last click that was generated using EF.click for a given user. This can be useful in scenarios where, for example, the user initially lands on the following URL : https://destination-url.com/page-A?oid=3&affid=5. The click is generated using

EF.click({
  offer_id: EF.urlParameter('oid'), 
  affiliate_id: EF.urlParameter('affid'),
});

If the user later navigates to https://destination-url.com/page-B, you can access the transaction ID by executing

var offerId = 3;
var efTid = EF.getTransactionId(offerId); 

The EF.getTransactionId method will return the latest transaction ID found. It will return an empty string if no transaction ID is found.

You can also access the latest transaction id for a specific advertiser ID, regardless of the offer ID.

var advertiserId = 1;
var efTid = EF.getAdvertiserTransactionId(advertiserId)
Conditional Clicks and Parameters

Of course, being able to extract the transaction ID means that you can add some conditional logic around the way your generate your clicks. For example, if you wish to generate a click only when there are no other transaction IDs stored in the user’s browser, you could add the following logic :

var offerId = 3;
var previousTransactionId = EF.getTransactionId(offerId);

if (!previousTransactionId) {
  EF.click({
    offer_id: offerId, 
    affiliate_id: EF.urlParameter('affid'),
  });
} else {
  // The user has already been on this page and already has the previousTransactionId
  // stored in the browser
}

Similarly, there may be situations in which you wish to attribute a click to “default values” if, for example, no offer id or affiliate id is supplied in the URL

var DEFAULT_OFFER_ID = 1;
var DEFAULT_AFFILIATE_ID = 10;

var offerId = EF.urlParameter('oid'); //Try and extract `oid` from the URL
if (!offerId) {
  offerId = DEFAULT_OFFER_ID; //Default to offer ID 1 if nothing was supplied in the URL
}

var affiliateId = EF.urlParameter('affid'); //Try and extract `affid` from the URL
if (!affiliateId) {
  affiliateId = DEFAULT_AFFILIATE_ID; //Default to affiliate ID 10 if nothing was supplied in the URL
}

EF.click({
  offer_id: offerId, 
  affiliate_id: affiliateId,
});