Server-to-Server (S2S) Tracking API

Track affiliate referrals server-side with the Discover Mac Apps S2S Tracking API for 100% ad-blocker resistance and Safari ITP bypass.

If you want 100% bulletproof tracking that is completely immune to adblockers, Intelligent Tracking Prevention (ITP), and brave-browser shields, you should implement our Server-to-Server (S2S) Backend API instead of using the frontend track.js script.

The Problem with Frontend Scripts

Frontend scripts are vulnerable. Over 40% of internet users use adblockers like uBlock Origin. These tools often block third-party scripts (like track.js) from loading, meaning you lose attribution data, and your affiliates lose their deserved commissions.

The Solution: Backend API

By shifting the tracking logic to your server (Node.js, Python, Go, etc.), the customer's browser never knows tracking is happening.

Step 1: Intercept the URL Parameter

When a user visits your site (e.g., yourmacapp.com?ref=AFFILIATE_CODE), your server must read that query parameter before responding with HTML.

Step 2: Ping our API securely

Make a background POST request from your server to our API.

// Example in Node.js / Express
app.get('/', async (req, res) => {
  const affiliateRef = req.query.ref;

  if (affiliateRef) {
    try {
      await fetch("https://discovermacapps.com/api/affiliate/pixel", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({
          programId: "YOUR_PROGRAM_ID",
          code: affiliateRef,
          ip: req.headers['x-forwarded-for'] || req.socket.remoteAddress,
          userAgent: req.headers['user-agent']
        })
      });
    } catch (err) {
      console.error("Tracking failed silently", err);
    }
  }
  
  // Continue rendering page...
});

[!TIP] Passing the ip and userAgent is highly recommended. It helps us prevent fraud and provides better analytics for your affiliates.

Step 3: Store the Cookie Yourself

Since you aren't using our frontend script, we cannot set the cookie on the user's browser. You must manually set a first-party cookie on your domain so you remember the affiliate ID when the user eventually goes to checkout (which could be days later).

// Set a 90-day cookie in your HTTP response
const ninetyDays = 90 * 24 * 60 * 60 * 1000;
res.cookie('dma_aff_ref', affiliateRef, { 
    maxAge: ninetyDays, 
    httpOnly: true, 
    secure: true, 
    sameSite: 'lax' 
});

Step 4: Pass the ID to Checkout

When the user clicks "Buy Now", read the dma_aff_ref cookie from their request, and pass it to your payment provider (Stripe, Whop, etc.) as metadata. Our webhooks will look for that metadata to attribute the sale.

Was this article helpful?
Still need help? Contact Support