Paid Social AdvertisingBudgets, bidding, tracking and consent · Lesson 8 of 17

Pixels, conversions APIs and data quality

Article · 16 min · 8 min lecture

Video lecture

Pixels and conversions APIs: feeding the algorithm clean data

11 chapters · about 8 min · full transcript

Coming soon

Chapter 1 of 11

Pixels and conversions APIs

  • Browser pixels
  • Server-side APIs
  • Deduplication and match quality
  • Cash on delivery
  • A real code example

The narrated lecture is in production

Every chapter is scripted and ready. Browse the chapters and read the full transcript now — the video will appear here when it’s published.

Chapters

Why conversion data matters more than ever

Ad platforms optimise towards the conversions you send them. If data is missing, delayed or wrong, the algorithm learns from a distorted picture, and your reported results are unreliable. With browser tracking limits, ad blockers and privacy changes, a single browser pixel often misses conversions.

Browser pixels

A pixel (Meta Pixel, TikTok Pixel, LinkedIn Insight Tag, X Pixel) is a small piece of JavaScript on your website. When someone takes an action, it sends an event to the platform, for example:

  • PageView
  • ViewContent
  • AddToCart
  • InitiateCheckout
  • Purchase (with value and currency)
  • Lead / CompleteRegistration

Pixels are easy to install through tag managers or e-commerce integrations (for example Shopify, WooCommerce or Salla apps), but they depend on the visitor's browser and consent choices.

Server-side conversions APIs

A conversions API (Meta Conversions API, TikTok Events API, LinkedIn Conversions API, X Conversion API) sends events directly from your server or a partner platform to the ad platform.

Benefits:

  • More resilient to browser restrictions and ad blockers.
  • Can include offline or back-end events (for example a lead that becomes a paying customer in your CRM, or a cash-on-delivery order that is actually delivered).
  • Often improves the platform's ability to match events to people.

Conversions APIs still require you to respect consent and privacy law. Sending data from a server does not make it lawful by itself.

Using both: deduplication

Best practice is usually to run both pixel and server events. To avoid counting the same purchase twice, send a shared event ID (and the same event name) from both sources so the platform can deduplicate. Test deduplication with the platform's diagnostic tools (for example Meta's Events Manager test events).

Match quality

Server events include customer information parameters (such as hashed email or phone, IP address, user agent and click IDs like fbclid or ttclid) that help the platform match an event to an ad interaction. More accurate, consented parameters generally improve event match quality, which improves attribution and optimisation. Personal identifiers must be hashed as the platform specifies and collected lawfully.

Priorities for iOS and aggregated measurement

Since Apple's App Tracking Transparency, platforms use aggregated and modelled measurement for some iOS traffic. Settings and requirements have evolved over time (for example, Meta has changed how it handles web event configuration). Keep your domain verified in each platform where required and follow current guidance in the platform's events manager.

Cash on delivery and offline conversions

In Pakistan and parts of the Gulf, many orders are cash on delivery (COD), and some are refused at the door. If you optimise for "Purchase" at checkout, the algorithm may learn to find people who order but do not pay. Options include:

  • Sending a separate "Delivered" or "Paid" event via the conversions API when the order is confirmed.
  • Using order-confirmation calls or WhatsApp confirmation before counting a conversion.
  • Comparing ad-reported purchases with delivered orders when evaluating campaigns.

Tracking QA checklist

  • Pixel installed once (not duplicated by a theme and a plugin).
  • Standard events fire at the right moment with correct value and currency.
  • Server events sent with event IDs matching browser events.
  • Consent choices respected: tags wait for consent where required.
  • Test purchase completed and visible in events manager.
  • UTMs on all ads for analytics cross-checking.
  • Domain verified in each ad account where required.

Worked example

A Riyadh fashion store sees Meta report 180 purchases while Shopify shows 140. Investigation finds the pixel fires twice: once from the theme and once from an app. After removing the duplicate and adding deduplicated server events, reported purchases align more closely with store data and CPA reporting becomes trustworthy.

Common mistakes

  • Duplicate pixels inflating conversions.
  • Missing value and currency on purchase events.
  • Server and browser events without matching event IDs.
  • Optimising for COD orders that are never paid.

How to implement: three routes

  1. Partner integration (easiest): Shopify, WooCommerce, Salla, Zid, BigCommerce and similar platforms offer official apps that send both pixel and server events with deduplication. Start here if your store platform supports it.
  2. Server-side tag manager or gateway: server-side Google Tag Manager, or a platform gateway product such as Meta's Conversions API Gateway, forwards events without custom code.
  3. Direct API calls from your backend: most control; needs a developer. Use this for CRM or delivery events that never happen in a browser.

Hands-on: sending a server event to Meta's Conversions API (Python)

A minimal, production-minded example. Keep secrets in environment variables, hash identifiers, reuse the browser's event_id and handle errors. Check Meta's docs for the current Graph API version before you ship.

import hashlib, os, time
import requests

PIXEL_ID = os.environ["META_PIXEL_ID"]
TOKEN = os.environ["META_CAPI_TOKEN"]          # never hard-code
API_VERSION = os.environ.get("META_GRAPH_VERSION", "v23.0")  # check current version

def sha256(v: str) -> str:
    return hashlib.sha256(v.strip().lower().encode("utf-8")).hexdigest()

def send_purchase(order: dict, consent_marketing: bool) -> None:
    if not consent_marketing:
        return  # respect the user's choice where consent is required
    # drop empty identifiers (e.g. no click cookie) rather than sending nulls
    order = {k: v for k, v in order.items() if v is not None}
    payload = {"data": [{
        "event_name": "Purchase",
        "event_time": int(time.time()),
        "event_id": order["event_id"],           # same ID the browser pixel sent
        "action_source": "website",
        "event_source_url": order["page_url"],
        "user_data": {
            "em": [sha256(order["email"])],
            "ph": [sha256(order["phone_e164"].lstrip("+"))],
            "client_ip_address": order["ip"],
            "client_user_agent": order["user_agent"],
            **({"fbc": order["fbc"]} if "fbc" in order else {}),  # _fbc cookie / fbclid
            **({"fbp": order["fbp"]} if "fbp" in order else {}),  # _fbp cookie
        },
        "custom_data": {"currency": order["currency"], "value": round(order["value"], 2)},
    }]}
    url = f"https://graph.facebook.com/{API_VERSION}/{PIXEL_ID}/events"
    try:
        r = requests.post(url, params={"access_token": TOKEN}, json=payload, timeout=10)
        r.raise_for_status()
    except requests.RequestException as exc:
        # log and queue for retry; never block the customer's checkout on this call
        print(f"CAPI send failed for order {order['event_id']}: {exc}")

While testing, add a test_event_code from Events Manager to the payload so events show in Test events without affecting reporting. TikTok's Events API, LinkedIn's Conversions API and Snap's Conversions API follow the same pattern (event name, time, deduplication ID, hashed identifiers, value) with their own field names – follow each platform's documentation.

Worked example 2: sending qualified leads back from a CRM

A Dubai property developer's Meta lead ads generated thousands of cheap leads, many unreachable. The team adds two CRM-triggered server events – qualified_lead (the sales team confirmed budget and timeline) and site_visit_booked – sent through the Conversions API with the lead's hashed email and phone. After enough events accumulate, they optimise a lead campaign towards qualified leads. Cost per lead rises; cost per site visit falls. The CRM, not the form, becomes the source of truth.

How to measure success

  • Deduplication working: platform purchases close to store orders for tracked journeys, with no double counting (check event overlap in Events Manager or each platform's diagnostics).
  • Match quality: Meta's event match quality score and similar diagnostics trend up as you add consented identifiers.
  • Coverage: share of store orders that reach each platform as server events, monitored weekly with an alert if it drops.

For server-side tagging, consent-aware CAPI set-ups and monitoring at a professional level, continue to Privacy-First Measurement.

Key takeaways

  • Platforms optimise towards the events you send, so data quality directly affects performance.
  • Use browser pixels plus server-side conversions APIs, deduplicated with shared event IDs.
  • Better, lawfully collected match parameters improve event match quality; consent still applies to server events.
  • For cash-on-delivery markets, consider sending delivered or paid events so optimisation targets real buyers.

Check your understanding

Quick questions to lock in the lesson. They don’t count towards your certificate.

  1. Why send a shared event ID from both the pixel and the conversions API?
  2. A COD-heavy store sees many ad-reported purchases but many refused deliveries. What is a good improvement?
  3. Which statement about conversions APIs is true?

Put it into practice

Run a tracking QA on a site you manage (or a test store): check for duplicate pixels, confirm purchase value and currency, and verify deduplication in the platform's test tool.

Enrol for free to save your progress

Reading is always free. Enrol to keep your place, take the final assessment and earn a verifiable certificate.