Meta · Track an eventStep 1 of 3

Track Purchase

The Purchase event fires the moment a visitor completes an order on your site — usually when they land on the “Thank you for your order” or order-confirmation page. This is the most important event Meta needs to optimize your ads, because it tells Smart Bidding which clicks lead to revenue.

Example of a thank-you / order-confirmation page on an e-commerce site
Purchase fires on the page that loads right after a successful order.

1. Copy the snippet

Pick one of the two formats below — whichever matches how you build your site. They both end up the same way on Meta.

Option A — pbq (recommended)

Same syntax as Meta’s standard pixel. Works out of the box on any custom site.

thank-you.html
<!-- Place inside the <body> of your order-confirmation /
     thank-you page, AFTER the AdsPing script in <head>. -->
<script>
  pbq('track', 'Purchase', {
    content_ids: ['SKU-1043'],
    content_type: 'product',
    num_items: 1,
    value: 24.90,
    currency: 'USD',
    order_id: 'ORDER-9381'   // enables cross-channel dedup
  });
</script>

Option B — dataLayer

Use this if your site already pushes events to window.dataLayer (e.g. via Google Tag Manager). AdsPing reads the dataLayer automatically.

thank-you.html
<!-- Place inside the <body> of your order-confirmation /
     thank-you page, AFTER the AdsPing script in <head>. -->
<script>
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({
    event: 'purchase',
    ecommerce: {
      transaction_id: 'ORDER-9381',
      value: 24.90,
      currency: 'USD',
      items: [
        { item_id: 'SKU-1043', item_name: 'Acme Hydrating Serum', quantity: 1, price: 24.90 }
      ]
    }
  });
</script>

2. Where to paste it

Paste it inside the <body> of your order-confirmation page (the page customers see after a successful order). It must run AFTER the AdsPing script you added in Step 2 — placing it anywhere in <body> guarantees that.

Code editor showing the Purchase snippet inside the body of the thank-you page
Inside <body> on the order-confirmation page.

Use real values, not the examples.

  • · value — the total amount the customer paid (number, no currency symbol).
  • · currency — 3-letter ISO code: USD, EUR, TRY etc.
  • · order_id / transaction_id — the unique order number from your system. Meta uses this to dedup, so make sure each real order has a unique value.
  • · If your platform renders the page from a template, replace the example values with template variables (e.g. {{ order.total }}).

3. Test it

Complete a real test order on your site (a free product, a coupon-discounted order, or whatever your platform allows). After you reach the thank-you page, open your AdsPing dashboard and look at Recent Events for this pixel. A new Purchase row should appear within 10 seconds with a green Success badge.

AdsPing Recent Events showing a Purchase event with a Success badge
A Success badge means the event reached AdsPing — and Meta.

To verify on the Meta side as well, paste a Meta Test Event Code into your pipeline. See the verification guide for the exact steps.

✓ Purchase is now live.

Every completed order on your site will be forwarded to Meta via the Conversions API — including for visitors with ad blockers or on iOS Safari.