…
Skip to content
Topics
On this page

Meta Pixel and Conversions API (CAPI)

The Meta Pixel and Conversions API are two ways of sending website events, such as purchases, to Meta. The Pixel is code in the visitor's browser. The Conversions API (CAPI) sends the same events from your server. Used together and deduplicated with a shared event_id, they give Meta more complete data to measure ads and find buyers.

  • Pixel: Browser code that fires events like ViewContent, AddToCart and Purchase.
  • Conversions API: Server-to-Meta events that do not depend on the browser.
  • Deduplication: The same event name and event_id on both, so each purchase counts once.
  • Consent: Both need a lawful basis, usually consent, before sending personal data.
  • Why it matters: Meta's delivery learns from these events, so gaps and duplicates mislead it.
Meta Pixel and Conversions API: one purchase from two sources, counted onceThe saree store sends the same purchase twice. From the browser, the Meta Pixel sends Purchase with event_id SRT-10482, but it may miss orders when customers pay in a UPI app and do not return. From the server, the Conversions API sends Purchase with the same event_id after the payment webhook confirms the order. Both are sent only with consent. Meta Events Manager sees the same event name and the same event_id and counts the purchase once.Browser: Meta PixelPurchaseevent_id: SRT-10482Sent only with consentServer: Conversions APIPurchaseevent_id: SRT-10482May miss UPI returnsAfter payment webhookMeta Events ManagerSame event nameand same event_idCounted onceSimplified illustration
Meta Pixel and Conversions API: one purchase from two sources, counted once

This tutorial follows one example: a D2C saree brand from Surat that sells on its own website. Most customers pay by UPI through a payment gateway. Many switch to their UPI app to pay and never come back to the thank-you page, so the brand's Pixel misses a share of real orders.

Prerequisites for the Meta Pixel and Conversions API

  • Admin access to Events Manager in the brand's business portfolio.
  • Website access: Admin access to the store platform, such as Shopify or WooCommerce, or a developer for a custom site.
  • Payment confirmation on the server: The site must know when the gateway confirms payment, usually through a webhook.
  • A consent banner and privacy notice that mention sharing data with Meta for advertising, in line with the DPDP Act.
  • A verified domain in the business portfolio.

Setup: Create the Dataset

  1. Open Events Manager and choose to connect a new data source for the web.
  2. Name it after the store and enter the website address.
  3. Choose how to connect: a partner integration, the Conversions API Gateway, or manual setup. For Shopify, Meta's sales channel app sets up both Pixel and CAPI together.
  4. Note the Pixel ID (dataset ID). For manual server setup, generate an access token in the dataset settings and store it only on the server.

Step-by-Step: Send Purchases from Browser and Server

Step 1: Install the Pixel Base Code

With a partner integration, this is automatic. On a custom site, paste the base code from Events Manager into the head of every page, or add it through Google Tag Manager as described in the Google Tag Manager tutorial. Load it only after the visitor has accepted marketing cookies.

Step 2: Fire Standard Events

Use Meta's standard event names so reports and optimization understand them: ViewContent on product pages, AddToCart, InitiateCheckout at checkout, and Purchase after payment. On the order confirmation page, the browser Purchase event carries an eventID:

JavaScript
fbq("track", "Purchase",
  { value: 4850.0, currency: "INR", content_ids: ["BANARASI-RED-01"], content_type: "product" },
  { eventID: "SRT-10482" }
);
  • value and currency: The order total in rupees, so Meta can report and optimize for revenue.
  • eventID: The order number. The server will send the same value.

Step 3: Send the Same Purchase from the Server

When the gateway's webhook confirms the UPI payment, the server sends the purchase to the Conversions API. This works even if the customer never returns to the site.

JSON
{
  "data": [
    {
      "event_name": "Purchase",
      "event_time": 1767254400,
      "event_id": "SRT-10482",
      "action_source": "website",
      "event_source_url": "https://example-saree-store.in/checkout",
      "user_data": {
        "em": ["<sha256 of lowercase email>"],
        "ph": ["<sha256 of phone with country code 91>"],
        "client_ip_address": "<visitor IP>",
        "client_user_agent": "<visitor browser user agent>",
        "fbp": "<value of the _fbp cookie>",
        "fbc": "<value of the _fbc cookie, if present>"
      },
      "custom_data": { "value": 4850.0, "currency": "INR", "order_id": "SRT-10482" }
    }
  ]
}
  • event_id: Exactly the same as the browser eventID, so Meta can deduplicate.
  • user_data: Email and phone are normalised and hashed with SHA-256 before sending. Send them only for customers who consented.
  • fbp and fbc: Browser cookies saved at checkout, which help Meta link the server event to the ad click.
  • event_time: When the purchase happened, in Unix seconds, sent soon after the event.

Step 4: Deduplicate

Meta treats a browser event and a server event as one when the event name and event_id match and they arrive within its deduplication window. If the IDs differ, every purchase counts twice, and Meta's AI learns from inflated numbers.

  • Browser: Do not load the Pixel until the visitor accepts marketing cookies.
  • Server: Record the consent choice with the order, and send server events with personal data only for customers who agreed. Server-side sending is not a way around a "no".
  • Minimum data: Never send sensitive details, such as health information, or anything in URLs that identifies a person.

The same thinking applies to server-side tags in general, covered in server-side tagging.

Step 6: Test

  1. In Events Manager, open Test events and copy the test code.
  2. Place a small real order with UPI, add the test code to the server request, and watch both events arrive.
  3. Check that the overview shows the Purchase as received from browser and server, and deduplicated.
  4. Remove the test code before going live.

Step 7: Check Event Match Quality and Real Orders

Events Manager shows an Event Match Quality score for server events. Improve it by sending more consented identifiers, not by guessing. Then compare Meta's reported purchases for a week with the store's real order list. A large gap means events are missing or doubled. For site-wide analytics, keep GA4 set up as shown in the GA4 tutorial.

Common Mistakes

  • Different IDs: The browser uses the cart ID and the server uses the order number, so nothing deduplicates.
  • Two integrations at once: A platform app and custom code both send purchases, doubling every order.
  • Unhashed personal data: Sending plain email or phone numbers instead of hashed ones.
  • Ignoring consent on the server: Treating CAPI as a way to track people who declined.
  • Wrong currency or value: Sending prices in paise, or leaving the currency as USD.
  • Late server events: Sending purchases in a nightly batch, long after they happened.
  • Never checking: Assuming it works without comparing with real orders.

Next Steps

How AI Changes the Meta Pixel and Conversions API

What AI Automates Now

Meta's AI uses these events to decide who sees each ad, to estimate conversions it cannot observe directly, and to suggest fixes in Events Manager diagnostics. AI coding assistants can also draft server code for CAPI requests and hashing, which a developer then reviews.

What Still Needs a Human

Choosing which events to send, deciding what data may be shared with consent, checking deduplication, and matching reported purchases with real orders all need people who know the store and the law.

Risk to Watch

Bad events train bad delivery. Duplicate purchases make weak ads look strong, and missing UPI orders make good ads look weak. AI-written tracking code can also send personal data unhashed; review every field before it goes live.

Do It with AI

Use this prompt to review a tracking plan before a developer builds it. It works in ChatGPT, Claude or Gemini. Do not paste real customer data or access tokens.

Prompt for ChatGPT, Claude or Gemini

You are a tracking specialist for a D2C store in India using the Meta Pixel and Conversions API. Store platform: [Shopify, WooCommerce or custom] Checkout and payment flow: [for example, UPI via a payment gateway with redirect and webhook] Events we want: [ViewContent, AddToCart, InitiateCheckout, Purchase] Consent setup: [how the banner works and what is recorded] 1. For each event, say where it fires in the browser, whether the server should also send it, and what the event_id should be. 2. List the user_data fields to send, which must be hashed, and when they may be sent given our consent setup. 3. Point out places in our payment flow where the browser may miss a purchase. 4. Give a test plan using Events Manager Test events. Do not include real customer data or access tokens. Mark anything I must confirm in Meta's documentation.

  1. Write down your checkout flow and consent setup honestly, including gaps.
  2. Run the prompt and give the plan to your developer or platform partner.
  3. Build, then test with a real UPI order and the test code.
  4. Compare a week of Meta purchases with your order list before trusting the numbers.

Check Before You Use It

  • Facts: Confirm parameter names, the API version and deduplication rules in Meta's developer documentation.
  • Brand fit: The consent banner and privacy notice should use the store's plain, friendly tone.
  • Compliance: Hash personal data, send it only with consent, never send sensitive data, and keep access tokens off the browser.

Quick Quiz

Pick an answer to check yourself. Nothing is saved.

Question 1 / 3

  1. 1. A Surat saree customer pays in a UPI app and never returns to the thank-you page. Which part can still record the purchase?

Frequently Asked Questions

What is the difference between the Meta Pixel and the Conversions API?

The Meta Pixel is code that runs in the visitor's browser and sends events such as purchases to Meta. The Conversions API sends the same events from your server. Using both means an event blocked or missed in the browser can still reach Meta from the server.

Do I need both the Pixel and the Conversions API?

Meta recommends using both. The browser Pixel captures on-site behaviour easily, and the server connection fills gaps from ad blockers, browser limits and pages the customer never returns to, such as after paying in a UPI app.

How does Meta avoid counting a purchase twice?

By deduplication. When the browser and server send the same event with the same event name and the same event_id, Meta keeps one and discards the other, as long as they arrive within Meta's deduplication window.

Is the Conversions API allowed under India's DPDP Act?

It can be used lawfully, but you need a valid basis, usually consent, and a clear notice explaining that data is shared with Meta for advertising. Send only what is needed, hash customer details, and respect people who decline.

What is Event Match Quality?

It is a score in Events Manager that shows how well the customer details sent with an event help Meta match it to a Meta account. Sending consented, hashed email and phone, plus browser identifiers, usually improves it.