Help me set up server‑to‑server conversions: privacy mapping, deduplication rules,…
- User
Help me set up server‑to‑server conversions: privacy mapping, deduplication rules, throttles, and monitoring.
Assistant
Help me set up server‑to‑server conversions: privacy mapping, deduplication rules, throttles, and monitoring.
The user wants to set up server-to-server (S2S) conversion tracking. This involves several key components:
Target Audience/Platform: The request is general, but usually, this refers to platforms like Meta (Facebook), Google Ads (Enhanced Conversions), TikTok, or Snap. I should provide a platform-agnostic guide but use common examples (like Meta) to illustrate specific mechanics since they are the most complex regarding deduplication and privacy.
Structure of the Response:
event_name + event_id logic).Drafting Content - Specific Details:
+1 from phone numbers or + from emails before hashing).event_id. If the browser sends event ID 123 and the server sends event ID 123, the platform deduplicates them. If the browser sends nothing and server sends ID 123, it's unique. If browser sends 123 and server sends 124, you get a duplicate conversion.Refining the Tone: Technical, actionable, structured. Use code snippets or pseudo-code where helpful.
Self-Correction during drafting:
Detailed Breakdown:
Privacy Mapping:
trim(), lower(), remove country code from phone (sometimes), remove dots from gmail (standard practice).SHA-256(hex).em (email), ph (phone), fn, ln, ct, st, zp, country.fbc (click id), fbp (browser id), client_ip_address, client_user_agent.Deduplication:
server vs website.event_name AND event_id match, discard duplicate.Throttling:
bottleneck (Node) or similar.Monitoring:
Let's assemble this into a clear guide.
Final Polish: Ensure the distinction between "deduplication between browser and server" and "deduplication of server retries" is clear.
Okay, ready to write. To set up a robust Server-to-Server (S2S) conversion infrastructure (often called Conversions API for Meta, Enhanced Conversions for Google, or Conversion API for TikTok), you need to treat your server as a secure, reliable data pipeline.
Here is the technical blueprint for setting up Privacy, Deduplication, Throttling, and Monitoring.
Ad platforms require Personally Identifiable Information (PII) to match a server event to a user. However, you must never send raw PII (plain text emails/phones).
The Process:
external_id. This is often the highest quality match signal.Code Logic (Node.js Example):
const crypto = require('crypto');
function normalizeAndHash(email) {
// 1. Normalize
const normalized = email.trim().toLowerCase();
// 2. Hash (SHA-256)
return crypto.createHash('sha256').update(normalized).digest('hex');
}
const userData = {
em: normalizeAndHash(user.email), // Hashed Email
ph: normalizeAndHash(user.phone), // Hashed Phone
external_id: user.id.toString() // Your internal DB ID
};
Privacy Parameters:
ldu (Limited Data Use): Specifically for Meta. You must send a flag indicating if the user has opted out of tracking in your app/website.
[ 'LDU' ]If you are running both Browser (Pixel/GTag) and Server tracking, you will count double conversions unless you handle deduplication.
The Strategy: The Event ID You must generate a unique ID for every event on your server and ensure the browser pixel sends the exact same ID.
event_id: "order_12345").How Platforms Handle It:
event_name and event_id within a 5-minute window, it counts it once.transaction_id.Implementation Checklist:
A on the server.A to the checkout success page.A.A.Ad platforms are strict about API spam. If you send 10,000 requests in a second from the same IP, you will be blocked.
Best Practices:
Throttling Logic (Pseudo-code):
// If you are not using a managed queue, implement a simple rate limiter
const limiter = new Bottleneck({
minTime: 100, // 1 request every 100ms (10 req/s)
maxConcurrent: 5
});
async function sendConversion(payload) {
// Wraps the API call in the limiter
await limiter.schedule(() => axios.post(adPlatformUrl, payload));
}
S2S integration is "invisible." If it breaks, you lose money silently. You need three layers of monitoring.
Layer A: HTTP Health (Infrastructure)
Layer B: Data Integrity (Application)
Layer C: Reconciliation (Business Logic)
SELECT COUNT(*) FROM orders WHERE date = today vs. "Conversions reported in FB Ads Manager."| Component | Key Action |
|---|---|
| Privacy | Normalize (lowercase/trim) -> SHA-256 Hash. Never send raw PII. |
| Deduplication | Pass a unique event_id from Server to Browser for every transaction. |
| Throttling | Use a job queue (e.g., Redis/BullMQ) to process events asynchronously. Batch requests. |
| Monitoring | Set up "Silent Failure" alerts. Monitor Event Match Quality scores weekly. |
Do you have a specific programming language (Python, Node, PHP) or ad platform (Meta, Google, TikTok) you are implementing this for right now? I can provide specific code snippets for that environment.