Back to BlogTechnical

How to Set Up Server-Side Tracking for Meta Ads

A step-by-step guide to implementing Meta's Conversions API for server-side tracking. Covers setup, testing, deduplication, and optimization.

Go Funnel Team9 min read

Why You Need Server-Side Tracking for Meta Ads

Meta's browser pixel is losing 20-40% of conversion data. Ad blockers block the pixel script. Safari limits cookies to 7 days. iOS ATT hides 75% of iPhone users from cross-app tracking. Every lost conversion means less data for Meta's optimization algorithm, which means worse targeting and higher CPAs.

Meta's Conversions API (CAPI) fixes this by sending conversion data from your server directly to Meta's servers. No browser dependency. No ad blocker interference. Meta reports that advertisers using CAPI alongside the pixel see an average 13% improvement in cost per result.

This guide walks through the full implementation, from initial setup to optimization.

Prerequisites

Before starting, make sure you have:

  • Meta Business Manager access with admin permissions
  • A Meta pixel already installed on your website (CAPI supplements the pixel, doesn't replace it)
  • Access to your website's backend (server code, ecommerce platform admin, or tag management)
  • A Meta access token (generated through Events Manager or the System User method)

Step 1: Generate Your Access Token

You need an access token to authenticate API calls to Meta's servers.

Method A: Events Manager (Simpler)

  1. Go to Meta Events Manager
  2. Select your pixel
  3. Click Settings
  4. Scroll to "Conversions API"
  5. Click "Generate access token"
  6. Copy and securely store the token

This token is linked to your personal account. For production systems, use Method B.

Method B: System User Token (Recommended for Production)

  1. Go to Business Settings > System Users
  2. Create a new System User (or use existing)
  3. Assign the pixel to the System User with "Manage" permission
  4. Generate a token with the ads_management and business_management permissions
  5. Set token expiration to "Never" for production use

System User tokens don't expire and aren't tied to a personal account, making them more reliable for automated systems.

Step 2: Choose Your Implementation Method

Option A: Shopify Built-In Integration

Best for: Shopify stores wanting the fastest setup.

  1. In Shopify admin, go to Settings > Customer Events
  2. Click "Add custom pixel" or configure the Meta channel
  3. Enable "Use Conversions API"
  4. Enter your pixel ID and access token
  5. Select which events to send (Purchase, AddToCart, InitiateCheckout at minimum)

Setup time: 15-30 minutes. Shopify handles deduplication, hashing, and event formatting.

Option B: Google Tag Manager Server-Side

Best for: Brands using GTM who want centralized tracking management.

  1. Set up a GTM server-side container (requires Google Cloud account)
  2. In your web GTM container, configure the GA4 tag to send data to your server container
  3. In the server container, add the "Facebook Conversions API" tag
  4. Configure the tag with your pixel ID and access token
  5. Map event parameters: event name, user data fields, custom data
  6. Set up the event ID variable for deduplication

Setup time: 4-8 hours including server container provisioning.

Option C: Direct API Integration

Best for: Brands with development resources who want maximum data quality.

The API endpoint: POST https://graph.facebook.com/v19.0/{PIXEL_ID}/events

A typical purchase event payload structure:

{
  "data": [
    {
      "event_name": "Purchase",
      "event_time": 1711670400,
      "event_source_url": "https://yoursite.com/thank-you",
      "event_id": "order_12345_1711670400",
      "action_source": "website",
      "user_data": {
        "em": ["a]hashed_email_sha256"],
        "ph": ["hashed_phone_sha256"],
        "fn": ["hashed_firstname_sha256"],
        "ln": ["hashed_lastname_sha256"],
        "ct": ["hashed_city_sha256"],
        "st": ["hashed_state_sha256"],
        "zp": ["hashed_zip_sha256"],
        "country": ["hashed_country_sha256"],
        "external_id": ["hashed_userid_sha256"],
        "client_ip_address": "192.168.1.1",
        "client_user_agent": "Mozilla/5.0...",
        "fbc": "fb.1.1234567890.AbCdEfGh",
        "fbp": "fb.1.1234567890.987654321"
      },
      "custom_data": {
        "value": 99.99,
        "currency": "USD",
        "content_ids": ["SKU123"],
        "content_type": "product",
        "num_items": 1,
        "order_id": "12345"
      }
    }
  ],
  "access_token": "YOUR_ACCESS_TOKEN"
}

Setup time: 20-40 development hours depending on your backend stack.

Step 3: Configure User Data Matching

The quality of your user data determines how well Meta can match your server events to Facebook/Instagram users. This directly impacts attribution accuracy and optimization performance.

Required Hashing

All personal identifiers must be SHA-256 hashed before sending. Meta never receives raw personal data.

Hashing rules:

  • Lowercase all text before hashing
  • Trim leading/trailing whitespace
  • Remove all formatting from phone numbers (just digits, with country code)
  • Hash with SHA-256 (no salt)

Example: Email "John.Doe@Gmail.com" becomes:

  1. Normalize: "john.doe@gmail.com"
  2. Hash: SHA-256("john.doe@gmail.com") = "a8b14c..."

Matching Parameters (Ranked by Impact)

| Parameter | Field | Impact on Matching | |-----------|-------|-------------------| | Email | em | Highest -- include always | | Phone | ph | High -- include when available | | First name | fn | Medium -- helps disambiguate | | Last name | ln | Medium -- helps disambiguate | | City | ct | Low-Medium | | State | st | Low-Medium | | Zip code | zp | Low-Medium | | Country | country | Low | | External ID | external_id | Medium -- consistent user identifier | | Facebook click ID | fbc | High -- direct click matching | | Facebook browser ID | fbp | Medium -- browser-based matching |

The fbc and fbp Parameters

These are critical for matching:

fbc (Facebook Click ID): Captured from the fbclid URL parameter when a user clicks a Meta ad. Store this value when the user arrives and include it in the CAPI event. This enables direct click-to-conversion matching.

fbp (Facebook Browser ID): A first-party cookie (_fbp) set by the Meta pixel. If you can read this cookie server-side and include it in the CAPI event, it provides additional matching signal.

Step 4: Implement Deduplication

Running pixel and CAPI simultaneously without deduplication doubles your conversion count. This is the most common implementation error.

How Deduplication Works

  1. Generate a unique event ID for each conversion (e.g., order_12345_timestamp)
  2. Pass this event ID in both the pixel event AND the CAPI event
  3. Meta receives both events, sees matching event IDs, and merges them into one

Pixel-Side Implementation

In your pixel event code, include the event ID:

fbq('track', 'Purchase', {
  value: 99.99,
  currency: 'USD',
  content_ids: ['SKU123']
}, { eventID: 'order_12345_1711670400' });

CAPI-Side Implementation

In your API call, include the same event ID:

{
  "event_name": "Purchase",
  "event_id": "order_12345_1711670400",
  ...
}

The event_id must be identical in both. If the pixel fires and CAPI sends the same event, Meta deduplicates. If the pixel is blocked (ad blocker), only the CAPI event arrives, and the conversion is still captured.

Verifying Deduplication

In Events Manager:

  1. Go to your pixel > Test Events tab
  2. Trigger a test conversion
  3. You should see one event listed with "Browser + Server" as the source
  4. If you see two separate events, deduplication isn't working -- check your event IDs

Step 5: Test Your Implementation

Use Meta's Test Events Tool

  1. In Events Manager, go to the Test Events tab
  2. Note the test event code provided
  3. Add the test_event_code parameter to your CAPI calls during testing
  4. Trigger conversion events on your site
  5. Verify they appear in the Test Events tab with correct data

Verify Event Match Quality

After 24-48 hours of production events:

  1. Go to Events Manager > Data Sources > Your Pixel
  2. Click the event name (e.g., "Purchase")
  3. Check Event Match Quality score
  4. Review the parameter match rate breakdown

Target an EMQ of 6.0+. If below 6.0, add more user data parameters to your events.

Common Test Failures and Fixes

| Issue | Symptom | Fix | |-------|---------|-----| | Wrong event ID format | Duplicate events appear | Ensure pixel and CAPI use identical event_id strings | | Missing email hash | Low EMQ (below 4) | Add hashed email to user_data in every event | | Wrong hash algorithm | 0% email match rate | Verify you're using SHA-256, not MD5 or another algorithm | | Uppercase in hash input | Low match rate | Always lowercase before hashing | | Stale access token | 401 errors in API responses | Regenerate token or use System User token |

Step 6: Monitor and Optimize

After implementation, ongoing monitoring ensures data quality stays high.

Daily Checks (Automated)

  • Event volume: Compare daily CAPI event count against expected conversions. A 20%+ drop signals a problem.
  • API error rate: Monitor HTTP response codes from Meta's API. 200 = success, 400+ = data issue, 500+ = Meta-side issue.

Weekly Checks

  • Event Match Quality: Track EMQ score weekly. A declining score means your data quality is degrading (possibly from code changes or fewer users providing email).
  • Deduplication rate: In Events Manager, check the percentage of events received from both browser and server vs. server-only. A healthy implementation shows 60-70% "Browser + Server" and 30-40% "Server Only" (the ad-blocked users).
  • Conversion comparison: Compare CAPI-reported conversions against your actual orders. The gap should be smaller than pixel-only comparison.

Monthly Review

  • Compare CAPI performance period-over-period
  • Review which user data parameters have the highest match rates
  • Identify opportunities to capture additional user data
  • Check for platform API updates that may require implementation changes

Frequently Asked Questions

How long does it take to see performance improvement after implementing CAPI?

Allow 2-4 weeks for Meta's algorithm to incorporate the improved conversion data into its optimization models. In the first week, you'll see more accurate reporting (higher conversion counts as CAPI captures what the pixel missed). By weeks 2-4, the algorithm uses this improved signal for better targeting and bidding. Full stabilization typically occurs by week 6-8. During this period, avoid making major campaign structure changes so you can isolate CAPI's impact.

Can I implement CAPI without the pixel?

Technically yes, but Meta doesn't recommend it. CAPI alone misses real-time browser context (scroll depth, referrer URL, session duration) that the pixel captures. The recommended setup is both pixel and CAPI with deduplication. The pixel handles real-time events and browser-side data. CAPI fills the gaps where the pixel fails. Together, they provide the most complete data set for Meta's optimization algorithm.

What happens if my CAPI sends incorrect data?

Incorrect data degrades Meta's optimization rather than improving it. Common problems: wrong currency code (sending GBP values as USD), including tax/shipping in conversion value inconsistently, or sending test events to production. If you discover bad data has been sent, there's no way to retroactively correct individual events through the API. You can adjust reporting in Ads Manager and fix the implementation going forward. For persistent data quality issues, Meta's Events Manager diagnostics tab shows warnings about detected problems.


Go Funnel uses server-side tracking and multi-touch attribution to show you which ads actually drive revenue. Book a call to see your real numbers.

Want to see your real ROAS?

Connect your ad accounts in 15 minutes and get attribution data you can actually trust.

Book a Call

Related Articles