Skip to main content
The Meta Ads integration sends conversions to Facebook and Instagram using Meta’s Conversions API (CAPI) for server-side tracking that bypasses browser limitations and improves attribution accuracy.

What Gets Synced

Ad Performance Data (From Meta):
  • Campaign, ad set, ad stats
  • Spend, impressions, clicks
  • CPM, CPC, CTR
  • Conversions reported by Meta
Conversion Data (To Meta):
  • Purchase events with revenue
  • Lead gen events
  • Signup/registration events
  • Add to cart, begin checkout events
  • Page view events
  • Custom events you configure

How It Works

Conversion Flow

1. User Clicks Meta Ad
User clicks Facebook ad on mobile
Meta appends fbclid to URL
URL: https://yoursite.com/?fbclid=IwAR123...
2. DATALYR Captures Click ID
DATALYR tracking script captures:
- fbclid: IwAR123...
- _fbp cookie (browser ID)
- _fbc cookie (click tracking)
Stores in visitor profile: anon_abc123
3. User Browses and Converts
User views products, adds to cart
User completes purchase: $99.99
4. Conversion Sent to Meta CAPI
DATALYR sends server-side conversion:
- Event: Purchase
- Value: $99.99
- fbclid: IwAR123 (from Day 1)
- Enhanced matching: email, phone (hashed)
- Deduplication with browser pixel
5. Meta Attributes Conversion
Meta receives conversion
Matches fbclid to original ad click
Attributes $99.99 to Facebook ad campaign
Updates campaign performance metrics
Result: Purchase correctly attributed to Meta ad, even if it happened days later or on different device.

Setup

1. Connect Meta Account

  1. Navigate to Settings → Sources in DATALYR
  2. Click “Connect” next to Meta Ads
  3. Log in to Facebook/Meta account
  4. Select Business Manager and ad account
  5. Grant permissions:
    • Read ad insights
    • Manage ads
    • Access Conversions API
  6. Click “Authorize”

2. Select Primary Ad Account

After connecting:
  1. DATALYR shows all accessible ad accounts
  2. Select your primary ad account for conversions
  3. Select the Meta Pixel to use for CAPI events
  4. Click “Save”

3. Configure Conversion Events

  1. Go to Settings → Conversion Rules
  2. Map your events to Meta standard events:
    • purchase → Purchase
    • add_to_cart → AddToCart
    • begin_checkout → InitiateCheckout
    • signup → CompleteRegistration
    • lead → Lead
  3. Set conversion values (optional):
    • Use order total for purchases
    • Fixed value for leads
    • LTV for signups

4. Verify Integration

Test Conversion:
  1. Click a Meta ad (use test ads if available)
  2. Complete a conversion on your site
  3. Go to Meta Events Manager
  4. Check “Test Events” tab
  5. Verify conversion appears with CAPI badge
Check Attribution:
  1. View conversion in DATALYR Event Stream
  2. Verify fbclid is present
  3. Confirm conversion sent to Meta (check logs)

Meta Conversions API (CAPI)

Why CAPI Matters

Browser Pixel Limitations:
  • iOS 14+ tracking restrictions
  • Ad blockers prevent pixel loading
  • Cookie consent requirements
  • Browser privacy features
CAPI Benefits:
  • Server-side tracking (no browser required)
  • Bypasses iOS tracking restrictions
  • Immune to ad blockers
  • More accurate attribution
  • Better event matching

How CAPI Works

Browser Pixel:
// Meta Pixel fires client-side
fbq('track', 'Purchase', {
  value: 99.99,
  currency: 'USD'
});
CAPI (Server-Side):
// DATALYR sends to Meta Conversions API
POST https://graph.facebook.com/v23.0/{pixel_id}/events
{
  "data": [{
    "event_name": "Purchase",
    "event_time": 1727634645,
    "event_id": "evt_123",
    "event_source_url": "https://example.com/checkout",
    "action_source": "website",
    "user_data": {
      "em": "hashed_email",
      "ph": "hashed_phone",
      "fbp": "_fbp_cookie",
      "fbc": "_fbc_click_cookie",
      "external_id": "user_456"
    },
    "custom_data": {
      "value": 99.99,
      "currency": "USD"
    }
  }]
}

Deduplication

DATALYR automatically deduplicates between browser pixel and CAPI: Event ID Matching:
  • Browser pixel: fbq('track', 'Purchase', {...}, {eventID: 'evt_123'})
  • CAPI: event_id: 'evt_123'
  • Meta deduplicates if event_id matches
How DATALYR Handles It:
// DATALYR uses consistent event IDs
Browser Pixel Event ID: evt_order_123_1727634645
CAPI Event ID:         evt_order_123_1727634645

Result: Meta counts as ONE conversion (not two)

Enhanced Matching

DATALYR sends hashed customer data to improve match rates:

Customer Data Sent

Always Hashed (SHA-256):
  • Email address
  • Phone number
  • First name
  • Last name
  • City, state, zip code
  • Country
Example:
// Original data (NEVER sent in plain text)
email: "[email protected]"

// Hashed with SHA-256 before sending
em: "b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514"

Browser IDs

_fbp (Facebook Browser Pixel):
  • First-party cookie set by Meta Pixel
  • Identifies browser/device
  • Format: fb.1.{timestamp}.{random}
_fbc (Facebook Click):
  • Contains fbclid from ad click
  • Tracks which specific ad was clicked
  • Format: fb.1.{timestamp}.{fbclid}
fbclid (Facebook Click ID):
  • Appended to URL by Meta ads
  • Unique identifier for each ad click
  • Used for attribution and conversion matching

Attribution

Cross-Device Attribution

DATALYR attributes conversions across devices using identity resolution: Example: Mobile (Day 1):
User clicks Facebook ad on mobile
fbclid captured: IwAR123
Visitor ID: anon_mobile_456
Desktop (Day 7):
User purchases on desktop
Different visitor ID: anon_desktop_789
BUT same email: [email protected]

DATALYR links:
1. anon_mobile_456 → [email protected]
2. anon_desktop_789 → [email protected]
3. Finds fbclid from anon_mobile_456
4. Sends conversion with original fbclid
Result: Desktop purchase attributed to mobile Facebook ad.

Attribution Windows

Meta Default Windows:
  • 7-day click attribution
  • 1-day view attribution
DATALYR Settings:
  • 30-day attribution window (default)
  • Configurable per workspace
If user clicks ad on Day 1 and converts on Day 35, conversion is NOT sent to Meta (outside window).

Event Mapping

Standard Events

Map your events to Meta standard events for better optimization:
Your EventMeta EventUse Case
purchasePurchaseE-commerce checkout
add_to_cartAddToCartAdd item to cart
begin_checkoutInitiateCheckoutStart checkout
signupCompleteRegistrationUser registration
leadLeadLead form submission
view_contentViewContentProduct page view
searchSearchSite search
add_payment_infoAddPaymentInfoPayment details entered

Custom Events

Send custom events for specific business needs:
// Track custom milestone
datalyr.track('trial_started', {
  plan: 'pro',
  trial_days: 14
});

// Maps to Meta custom event
Event Name: trial_started
Custom Data: {plan: 'pro', trial_days: 14}

Advanced Features

Action Source

DATALYR automatically sets the correct action_source: website: Web-based conversions (default)
User converts on website
action_source: "website"
app: Mobile app conversions
User converts in iOS/Android app
action_source: "app"
physical_store: Offline conversions
User purchases in store
action_source: "physical_store"

Limited Data Use (LDU)

For California (CCPA) and other privacy-restricted regions:
// DATALYR automatically sets LDU for California users
{
  "data_processing_options": ["LDU"],
  "data_processing_options_country": 1, // USA
  "data_processing_options_state": 1000 // California
}

Test Events

Test conversions before going live:
  1. Enable test mode in DATALYR
  2. Create test conversion
  3. Check Meta Events Manager → Test Events
  4. Verify data is correct
  5. Disable test mode for production

Troubleshooting

Conversions Not Appearing in Meta

Check:
  1. Integration is connected and active
  2. Meta Pixel ID is correct
  3. Event has fbclid or _fbp cookie
  4. Event is within attribution window (30 days)
  5. Check Events Manager for errors
Common Issues:
  • Missing fbclid: User didn’t come from Meta ad
  • Duplicate event IDs: Check deduplication
  • Invalid user data: Email/phone must be hashed

Low Match Rate

Improve matching by:
  1. Send email with every conversion
  2. Include phone number when available
  3. Send full address data (city, state, zip)
  4. Ensure _fbp and _fbc cookies are captured
Check:
Meta Events Manager → Data Sources → Your Pixel → Match Quality
Target: 60%+ match rate

Attribution Discrepancies

DATALYR vs Meta Numbers: Common reasons for differences:
  • Attribution windows differ (DATALYR: 30d, Meta: 7d)
  • View-through attribution (Meta counts, DATALYR doesn’t by default)
  • Conversion time differences (DATALYR uses event time, Meta uses ad time)
Best Practice: Use DATALYR for truth, Meta for optimization signals.

Data Privacy

Customer Data:
  • All emails, phones, names are SHA-256 hashed
  • No plaintext PII sent to Meta
  • GDPR and CCPA compliant
  • Opt-out respected
Hashing Example:
// Before hashing
Email: "[email protected]"

// After hashing (sent to Meta)
em: "b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514"

// Meta matches hash to their users without seeing email

Next Steps

Need Help?

Questions about Meta Ads integration? Check our troubleshooting guide or contact support.