Skip to main content

JavaScript Postback as an Alternative to S2S Tracking

This guide explains what a JavaScript Postback code is, how it works, when it’s useful, and what limitations you should keep in mind before implementing it.

HilltopAds avatar
Written by HilltopAds
Updated this week

What Is JavaScript Postback Code Integration?

A JavaScript Postback code is a small browser script placed on a webpage or landing page. Its purpose is to fire specific events and transmit tracking data back to an ad network, tracker, or analytics platform. It can track user actions and behavior, and collect browser-based data.

This type of client-side tracking is one of the oldest and simplest integration methods, widely used across digital advertising platforms: from Google Ads and Meta to affiliate networks and AdTech platforms like HilltopAds.

How Does It Work?

JavaScript Postback code tracking works by running a small script in the user’s browser that sends information to an advertising or analytics platform. Here’s the process broken down into simple steps:

  1. A JavaScript snippet is added to a webpage
    Typically at the end of the <body> tag.

  2. When the user loads the page, the browser executes the script.

  3. The pixel extracts necessary information, such as query parameters (e.g., clickId), cookies, user agent, IP, or referrer.

  4. The script assembles a request URL that includes the relevant event parameters.

  5. The browser sends the request to the advertising platform’s server.

  6. The ad network logs the event, attributing it to the correct click or session.

    Example: Hilltop Ads JavaScript Postback code

This snippet sends a conversion event using the clickId passed in the URL:

<script>
const urlParams = new URLSearchParams(window.location.search),
clickId = urlParams.get('clickId');
const postbackUrl = "https://trackhta.com/close/?token="
+ clickId + "&price=price&currency=currency&label=label&advertiserId=";

console.log(postbackUrl);

fetch(postbackUrl)
.then(function(response) {
console.log('Postback successful:', response);
})
.catch(function(error) {
console.error('Error during postback:', error);
});
</script>

This snippet is typically placed on a thank you or conversion confirmation page (e.g. “Thank you for your order!”) to ensure the event fires only after a completed action.

Limitations of JavaScript Postback code (Very Important!)

While convenient, JS pixel tracking comes with limitations you should keep in mind:

Limitation

Why It Matters

Can be blocked by ad blockers

Up to 30–40% of users prevent pixels from firing

Affected by browser privacy rules (ITP)

Safari & iOS aggressively limit cookies and client-side tracking

Depends on JavaScript execution

Script errors, slow connections, or blocked resources break tracking

Less accurate than S2S

Not guaranteed to fire in all scenarios

User may close the page too quickly

If the page doesn’t load fully, the pixel won’t fire

Because of these reliability concerns, advertisers operating in high-accuracy verticals (iGaming, finance, betting, crypto) typically prefer S2S postback integration as their main method, using JS pixels only as a backup or for additional event tracking.

Where to insert it?

The most common and recommended installation method is placing the script on a conversion confirmation page.

Add the snippet at the bottom of the page, before the closing tags:

</body>

</html>

Conclusion

JavaScript Postback is a simple, fast, and widely compatible way to record conversions, however, we highly recommend considering a dedicated tracking platform if possible. A tracker ensures reliable attribution, protects you from data loss, and provides advanced analytics and optimization capabilities that client-side scripts alone cannot offer. Check our postback guides to find the best option!

Did this answer your question?