This guide explains how to implement Aftrad's postback pixel on your landing page.
The integration consists of two scripts:
Script 1 (Click pixel) — captures the Aftrad click ID from the landing page URL and stores it in a cookie.
Script 2 (Conversion pixel) — reads the stored click ID and fires a postback to Aftrad when a conversion occurs.
How it works
When an Affiliate sends a user to your landing page (offer), Aftrad appends a click_id parameter to the URL. Script 1 captures this value and stores it in a cookie called aftrad_click_id. When the user completes a conversion on your website (e.g., a purchase or registration), Script 2 reads the cookie and fires the postback URL to Aftrad with the stored click ID.
Script 1 — Click pixel
Place this script on every landing page that receives traffic from Aftrad. It reads the click_id parameter from the URL and stores it in a cookie valid for 30 days.
<script>
(function() {
var params = new URLSearchParams(window.location.search);
var clickId = params.get('click_id');
if (clickId) {
var expires = new Date();
expires.setDate(expires.getDate() + 30);
document.cookie = 'aftrad_click_id=' + encodeURIComponent(clickId)
+ '; expires=' + expires.toUTCString()
+ '; path=/; SameSite=Lax';
}
})();
</script>
💡 Tip: Place this script as high as possible in the <head> section of your landing page to ensure the click ID is captured before any other scripts run.
Script 2 — Conversion pixel
Place this script on the conversion confirmation page (e.g., thank you page, order confirmation page). It reads the aftrad_click_id cookie and fires the postback to Aftrad.
Before using this script, replace https://your-postback-url.com with the actual Aftrad Postback URL provided to you.
<script>
(function() {
function getCookie(name) {
var match = document.cookie.match(
new RegExp('(?:^|; )' + name + '=([^;]*)')
);
return match ? decodeURIComponent(match[1]) : null;
}
var clickId = getCookie('aftrad_click_id');
if (clickId) {
var postbackUrl = 'https://your-postback-url.com/api/v1/events?click_id='
+ encodeURIComponent(clickId);
var img = new Image();
img.src = postbackUrl;
}
})();
</script>
⚠️ Important: Replace https://your-postback-url.com with the Postback URL provided by your Aftrad account manager before deploying this script.
💡 Tip: The postback is fired using a 1×1 pixel image request (GET), which is the standard method for server-to-browser postback firing. No visible element is added to your page.
Optional — Passing additional parameters
If you want to pass additional data in the postback (e.g., the payout amount or event type), you can extend the postback URL in Script 2:
var postbackUrl = 'https://your-postback-url.com/api/v1/events?click_id=' + encodeURIComponent(clickId) + '&payout=YOUR_PAYOUT_VALUE' + '&event_parameter=YOUR_EVENT_NAME';
Replace YOUR_PAYOUT_VALUE and YOUR_EVENT_NAME with the actual values from your platform, or with dynamic variables if your website CMS or tag manager supports them.
Implementation checklist
Before going live, verify the following:
[ ] Script 1 is installed on all landing pages that receive Aftrad traffic.
[ ] Script 2 is installed on the conversion confirmation page only.
[ ] The Postback URL in Script 2 has been replaced with the actual URL provided by your Aftrad account manager.
[ ] You have tested the full flow: click on a test link → verify the
aftrad_click_idcookie is set → complete a test conversion → verify the postback is received in Aftrad.
Troubleshooting
The cookie is not being set
Verify that the landing page URL contains a
click_idparameter.Check that Script 1 is loaded before any page redirects occur.
Ensure the user's browser allows cookies from your domain.
The postback is not being received in Aftrad
Verify that the Postback URL in Script 2 is correct and complete.
Check your browser's developer tools (Network tab) to confirm the pixel request is being fired on the conversion page.
Ensure the
aftrad_click_idcookie exists on the conversion page — it may have expired or been blocked.
Related articles