What is Webgains Deduplication Solution?
Webgains Deduplication Solution
Webgains cannot independently detect when another network is involved in a customer’s journey. Merchants need to implement a deduplication solution that tracks which network or marketing channel referred the customer last.
Webgains uses a tracking parameter like wgdp=webgains
that is added to the URL when a customer clicks on an affiliate link. This parameter helps the system identify Webgains traffic and compare it with other networks.
If another network’s link is clicked, their parameter (e.g., wgdp=networkB
) will overwrite the previous one. The tracking code for only the last-click network will fire, ensuring the correct network is credited.
Before implementing any de-duplication solutions, please ensure you have updated your De-Duplication Policy in your Program Terms and Conditions .
Local Tracking Setup Rules
If a customer is referred by Network A, only Network A's tracking code will fire.
If referred by Network B, only Network B's tracking code will fire.
If there is no referral, tracking codes for all networks will fire.
The merchant's cookie should remain active for the same duration as the affiliate network’s cookie.
Example Code for Deduplication Using Cookies
Here is an example of how you can set up a deduplication solution using JavaScript to manage cookies:
1. Set the Cookie Based on the Referral Source:
This script will set a cookie with the referral source whenever a customer clicks on a link from an affiliate network:
// Function to set a cookie
function setReferralCookie(referrer, days) {
const date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
const expires = "expires=" + date.toUTCString();
document.cookie = "referralSource=" + referrer + ";" + expires + ";path=/";
}
// Get referral source from URL parameters
const urlParams = new URLSearchParams(window.location.search);
const referrer = urlParams.get('wgdp');
// If there's a referral source in the URL, set the cookie
if (referrer) {
setReferralCookie(referrer, 30); // Cookie will last for 30 days
}
2. Get the Cookie Value and Fire the Appropriate Conversion Script:
This script will check the value of the referral cookie and load the correct tracking code based on the last-click referral source:
// Function to get the value of a cookie
function getCookie(name) {
const nameEQ = name + "=";
const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i++) {
let cookie = cookies[i].trim();
if (cookie.indexOf(nameEQ) === 0) return cookie.substring(nameEQ.length, cookie.length);
}
return null;
}
// Function to fire the tracking script
function fireTrackingScript(referrer) {
if (referrer === 'webgains') {
// Load Webgains tracking code
console.log('Firing Webgains tracking script...');
// Add your Webgains tracking script here
} else if (referrer === 'networkB') {
// Load Network B tracking code
console.log('Firing Network B tracking script...');
// Add Network B tracking script here
} else {
// Load all tracking codes if no referrer is found
console.log('Firing tracking scripts for all networks...');
// Add all networks' tracking scripts here
}
}
// Get the referral source from the cookie
const referralSource = getCookie('referralSource');
// Fire the appropriate tracking script
if (referralSource) {
fireTrackingScript(referralSource);
} else {
// If no cookie is found, fire all tracking scripts
fireTrackingScript(null);
}
Testing Local Tracking
To test if local tracking works correctly:
Click through a test affiliate link.
Check if the correct tracking parameter (e.g.,
wgdp=webgains
) appears in the URL once redirected to the merchant's site.Close the browser and start a new session to simulate a fresh customer visit.
Place an order and check if the appropriate tracking code fires based on the cookie.
Test if the code works when the tracking parameter is missing to ensure that the cookie-less tracking works.
Webgains teams can support through the set up of local tracking, and help test thoroughly to ensure that the program tracking is set up correctly. If you have any questions please contact your account manager or support@webgains.com.