Integration Guides · 6 MIN

How to set up Meta Conversions API with the Pixel without double counting

Send server-side Meta Conversions API events alongside the browser Pixel, deduplicate them with a shared event ID, and hash customer data the way Meta expects.

By NactorePublished 20 Nov 2026All articles

To set up Meta Conversions API with the Pixel, send each conversion twice, once from the browser with fbq and once from your server to the Graph API, and give both copies the same event name and event ID. Meta keeps one and discards the other. This guide shows the server code in Python, the matching Pixel call, and the hashing rules that trip people up.

Key takeaways
  • Meta deduplicates a Pixel event and a server event when the event name and event ID match, within 48 hours.
  • Email and phone are normalized, then SHA-256 hashed. IP address, user agent, fbp and fbc are sent unhashed.
  • Indian phone numbers need the 91 country code before hashing, even if every customer is in India.
  • An event older than seven days makes Meta reject the whole request, not just that event.
  • Our hashing code reproduces the example hashes in Meta's own documentation, and the request was tested against a local mock of the Graph API.
  • Nactore is a technology and growth company that builds, ships, ranks and grows products, and we run this setup for our own paid launches.

What does the Conversions API add to the Pixel?

The Meta Conversions API sends conversion events from your server straight to Meta, so a purchase still counts when an ad blocker or browser privacy setting stops the Pixel. The Pixel still matters because it carries browser signals. Running both, with deduplication, gives Meta the fullest picture of each conversion.

SetupStrengthWeakness
Pixel onlyEasy, rich browser signalsLost when the script is blocked
Conversions API onlySurvives blockers, server truthFewer browser signals
Both, deduplicatedBest coverageNeeds a shared event ID

How does Pixel and Conversions API deduplication work?

Meta treats two events as the same conversion when the Pixel eventID equals the server event_id and the event names match. The deduplication guide says this only works within 48 hours of the first event Meta receives with that ID. A missing or different ID means both copies count.

The easiest shared ID is one your system already has. For a purchase we use the payment order ID, which both the thank-you page and the server know.

Step 1: Send the server event

In Events Manager, select your Pixel, open Settings, and under Conversions API click Generate access token, as the get started guide describes. Keep the token on the server.

# meta_capi.py
import hashlib, json, os, time, urllib.parse, urllib.request

PIXEL_ID = os.environ["META_PIXEL_ID"]
TOKEN = os.environ["META_CAPI_TOKEN"]
GRAPH = os.environ.get("META_GRAPH_BASE", "https://graph.facebook.com/v27.0")


def _sha256(value):
    return hashlib.sha256(value.encode()).hexdigest()


def normalize_email(email):
    return email.strip().lower()


def normalize_phone(phone, default_country_code="91"):
    digits = "".join(ch for ch in phone if ch.isdigit()).lstrip("0")
    return digits if len(digits) > 10 else default_country_code + digits


def send_event(event_name, event_id, *, source_url, client_ip, user_agent,
               email=None, phone=None, fbp=None, fbc=None,
               value=None, currency="INR", test_event_code=None):
    user_data = {
        "client_ip_address": client_ip,   # never hashed
        "client_user_agent": user_agent,  # never hashed
        "fbp": fbp,                       # _fbp cookie, never hashed
        "fbc": fbc,                       # _fbc cookie, never hashed
    }
    if email:
        user_data["em"] = [_sha256(normalize_email(email))]
    if phone:
        user_data["ph"] = [_sha256(normalize_phone(phone))]
    event = {
        "event_name": event_name,
        "event_time": int(time.time()),
        "event_id": event_id,             # same value the browser Pixel sends as eventID
        "action_source": "website",
        "event_source_url": source_url,
        "user_data": {k: v for k, v in user_data.items() if v},
    }
    if value is not None:
        event["custom_data"] = {"value": value, "currency": currency}
    payload = {"data": [event]}
    if test_event_code:
        payload["test_event_code"] = test_event_code
    url = f"{GRAPH}/{PIXEL_ID}/events?" + urllib.parse.urlencode({"access_token": TOKEN})
    req = urllib.request.Request(url, data=json.dumps(payload).encode(), method="POST",
                                 headers={"Content-Type": "application/json",
                                          "User-Agent": "yourapp-capi/1.0"})
    with urllib.request.urlopen(req, timeout=10) as resp:
        return json.load(resp)

Call it after the payment is verified on your server. In Django, the IP, user agent and Meta cookies come from the request.

send_event(
    "Purchase", order.razorpay_order_id,
    source_url="https://yourdomain.com/thanks/",
    client_ip=request.META.get("REMOTE_ADDR"),
    user_agent=request.headers.get("User-Agent"),
    email=customer_email, phone=customer_phone,
    fbp=request.COOKIES.get("_fbp"), fbc=request.COOKIES.get("_fbc"),
    value=499, currency="INR",
)

Behind a proxy or load balancer, REMOTE_ADDR is the proxy, so read the client IP from the header your host documents.

Step 2: Fire the Pixel event with the same ID

On the thank-you page, pass the same ID as eventID in the fourth argument, using the syntax from Meta's guide.

fbq("track", "Purchase", { value: 499, currency: "INR" }, { eventID: "order_TEST123" });

Render the real order ID into the page from your server. The event name must match exactly: Purchase on both sides.

Step 3: Test before you trust the numbers

  1. Get a test code. In Events Manager, open your dataset and the Test Events tab, then copy the code.
  2. Send with test_event_code. Pass it to send_event and complete one test purchase in the browser.
  3. Check both sources. The event should appear once, with the browser and server both listed.
  4. Remove the code. Meta's Conversions API guide says to use it for testing only.

We checked the hashing against the worked examples in Meta's customer information parameters page. John_Smith@gmail.com and the US number (650)555-1212 both produce the exact hashes printed there.

Pro tip

Phone numbers are the quiet failure. A 10-digit Indian mobile hashed without 91 still looks valid, it just never matches anyone. normalize_phone adds the code when it is missing, so pass the right default for non-Indian customers.

What went wrong for us

ProblemWhat we sawFix
Conversion choice rejectedA LEAD event was refused as the optimization event under the Sales objectiveRun lead campaigns under the Leads objective
Double counted purchasesPixel and server copies with different IDsOne shared ID from the order
Whole batch rejectedOne event older than seven daysSend events as they happen
Token in logsThe token travels in the URLNever log full request URLs

Frequently asked questions

Do I still need the Meta Pixel if I use the Conversions API?

Keep both. Meta's setup guide tells you to use the same Pixel ID for browser and server events, and deduplication exists so the two can run together. The server copy survives blockers and the browser copy carries signals the server does not have.

Should I hash the IP address or user agent?

No. Meta's parameter reference says the client IP address, user agent, fbp and fbc must not be hashed. Email and phone must be normalized and hashed with SHA-256.

Which Graph API version should I use?

Use the version shown in Meta's current Conversions API docs. At the time of writing their examples use v27.0, and the code keeps the base URL in one constant so it is easy to update.

How long does Meta wait to deduplicate events?

Meta deduplicates events received within 48 hours of the first event with that event ID.

When to get help

If your ad platform and your payment provider disagree on conversions, the gap is usually tracking, not the ads. Send us the symptoms or see what we build. For the payment side of this flow, read how to integrate Razorpay in Django. Nactore is one partner that builds, ships, ranks and grows, measured on your growth.

Want to apply this to your business?

Book a free 30-minute call. We will tell you what we would do first.