Facebook Pixel uses URL parameters for ad tracking, attribution, and conversion measurement. Understanding these parameters helps you debug campaigns and build accurate attribution models.
Key Takeaways
- 1fbclid identifies clicks from Facebook ads and organic posts
- 2Custom conversions can match URLs or URL parameters
- 3Dynamic ads use catalog parameters for product retargeting
- 4Pixel events can pass URL data for enhanced matching
- 5iOS 14.5+ tracking requires Conversions API fallback
“The Meta Pixel is a piece of code on your website that can help you better understand the effectiveness of your advertising and the actions people take on your site.”
The fbclid Parameter
When users click links in Facebook ads or posts, the platform automatically appends a unique fbclid parameter to the destination URL. This parameter is the backbone of Facebook's attribution system, connecting ad clicks to conversions on your website.
https://example.com/product?fbclid=IwAR1234567890abcdefghijklmnopqrstuvwxyz
# fbclid structure:
# - Starts with IwAR (or similar prefix)
# - Contains encoded click data
# - Valid for 7 days
# - Unique per clickThe fbclid value encodes click metadata including timestamp, ad placement, and user session information. Facebook uses this to attribute conversions to specific ad campaigns, even across multiple browsing sessions within the 7-day attribution window.
Beyond fbclid, Facebook uses several other parameters to track different types of interactions and attribution scenarios. The following table shows the most common parameters you will encounter in your URLs.
Common Facebook Parameters
| Parameter | Purpose | Example |
|---|---|---|
| fbclid | Click attribution | IwAR1x2y3z... |
| fb_action_ids | Action tracking | 12345,67890 |
| fb_action_types | Action type | og.likes |
| fb_source | Traffic source | ticker,profile |
| ref | Referral tracking | nf,ts,tn |
Each parameter serves a specific attribution purpose. The fbclid is most critical for ad tracking, while ref and fb_source help identify organic Facebook traffic from different surfaces like the news feed or profile pages.
Custom conversions let you track specific user actions based on URL patterns. This is particularly useful when you cannot modify page code to fire pixel events directly, or when you want additional conversion tracking alongside standard events.
Custom Conversion URLs
// Custom conversion rules use URL matching
// You can match on:
// 1. URL contains
// Rule: URL contains "/thank-you"
// Matches: https://shop.com/checkout/thank-you?order=123
// 2. URL equals
// Rule: URL equals "https://shop.com/success"
// Matches: Only exact URL
// 3. URL parameter
// Rule: URL contains "purchase=complete"
// Matches: https://shop.com/checkout?purchase=complete
// Best practice: Use specific URL patterns
// Bad: /checkout (too broad)
// Good: /checkout/complete?confirmed=trueThis code demonstrates the three URL matching strategies Facebook supports. The "contains" approach is flexible but can trigger false positives, while "equals" requires exact matches. For most ecommerce sites, combining path and parameter matching provides the best accuracy.
Dynamic ads automatically show users products they have viewed or added to cart. To power this personalization, your URLs need to include product identifiers that match your catalog data.
Dynamic Ads Parameters
// Product catalog parameters for dynamic retargeting
// Landing page with product context
const productUrl = new URL('https://shop.com/product/shoes-123');
productUrl.searchParams.set('content_type', 'product');
productUrl.searchParams.set('content_ids', 'SKU-SHOES-123');
productUrl.searchParams.set('content_name', 'Running Shoes');
productUrl.searchParams.set('content_category', 'Footwear > Running');
productUrl.searchParams.set('value', '89.99');
productUrl.searchParams.set('currency', 'USD');
// Product page pixel event
fbq('track', 'ViewContent', {
content_ids: ['SKU-SHOES-123'],
content_type: 'product',
content_name: 'Running Shoes',
content_category: 'Footwear/Running',
value: 89.99,
currency: 'USD'
});
// The URL parameters help with:
// - Server-side validation
// - Debugging pixel fires
// - Fallback trackingThe code above shows how to include catalog parameters both in the URL and in the pixel event. This redundancy ensures that even if the pixel fails to fire, server-side validation can still capture product context. The content_ids must match your product catalog exactly for dynamic retargeting to work.
You can enhance pixel events by extracting data directly from the current URL. This approach is especially useful for thank-you pages where order details are passed as query parameters.
URL-Based Pixel Events
// Pass URL data to pixel events for enhanced matching
// Get URL parameters
const urlParams = new URLSearchParams(window.location.search);
// Purchase with full URL context
fbq('track', 'Purchase', {
value: parseFloat(urlParams.get('order_total')) || 0,
currency: 'USD',
content_ids: urlParams.getAll('product_id'),
content_type: 'product',
num_items: parseInt(urlParams.get('quantity')) || 1,
// Enhanced matching from URL
external_id: urlParams.get('customer_id'),
order_id: urlParams.get('order_id'),
// Landing page for attribution
event_source_url: window.location.href
});
// Lead with form data in URL
fbq('track', 'Lead', {
content_name: urlParams.get('form_name') || 'Contact Form',
content_category: urlParams.get('source') || 'Website',
value: parseFloat(urlParams.get('lead_value')) || 0,
currency: 'USD'
});This code extracts purchase and lead data from URL parameters to enrich pixel events. The event_source_url property is particularly important as it tells Facebook exactly which page triggered the conversion, improving attribution accuracy.
With iOS 14.5+ privacy changes limiting browser-side tracking, the Conversions API (CAPI) provides a server-side fallback that is not affected by cookie restrictions or ad blockers. Your server sends conversion data directly to Facebook, using the fbclid from the original URL click.
Conversions API URL Handling
// Server-side event with URL data
const serverEvent = {
event_name: 'Purchase',
event_time: Math.floor(Date.now() / 1000),
event_source_url: 'https://shop.com/thank-you?order=12345',
action_source: 'website',
user_data: {
client_ip_address: req.ip,
client_user_agent: req.headers['user-agent'],
fbc: req.cookies._fbc, // Facebook click cookie
fbp: req.cookies._fbp, // Facebook browser cookie
// Enhanced matching
em: hashEmail(user.email),
ph: hashPhone(user.phone)
},
custom_data: {
value: order.total,
currency: 'USD',
content_ids: order.items.map(i => i.sku),
content_type: 'product',
order_id: order.id
}
};
// fbc format: fb.1.{timestamp}.{fbclid}
// Extract fbclid from URL for fbc generation
function generateFbc(fbclid) {
const timestamp = Date.now();
return `fb.1.${timestamp}.${fbclid}`;
}The server event includes the original fbclid (extracted from URL on the landing page and stored in the _fbc cookie), user matching data, and conversion details. The generateFbc function shows how to format the fbclid into the cookie format that Facebook expects. Sending both pixel and CAPI events enables deduplication based on the order_id.
When conversions are not tracking correctly, you need tools to inspect what the pixel is actually sending. The Facebook Pixel Helper browser extension is essential for debugging, and your test URLs should include debug flags.
Debugging URLs
// Facebook Pixel Helper extension shows:
// - Event name and parameters
// - URL at time of event
// - Any errors or warnings
// Test URLs for pixel verification
const testUrls = {
viewContent: 'https://shop.com/product/test-123?debug=1',
addToCart: 'https://shop.com/cart?action=add&sku=TEST-123',
purchase: 'https://shop.com/thank-you?order=TEST-001&total=99.99'
};
// Verify pixel fires with test mode
fbq('init', 'YOUR_PIXEL_ID', {}, { debug: true });
// Check fbclid handling
function debugFbclid() {
const url = new URL(window.location.href);
const fbclid = url.searchParams.get('fbclid');
if (fbclid) {
console.log('fbclid present:', fbclid);
console.log('_fbc cookie:', document.cookie.match(/_fbc=([^;]+)/)?.[1]);
} else {
console.log('No fbclid in URL');
}
}The debugFbclid function helps you verify that the fbclid parameter is being preserved and that the _fbc cookie is being set correctly. If the cookie is missing when fbclid is present, check that your cookie domain is configured correctly and that third-party cookie blocking is not interfering.
To maximize attribution accuracy and avoid common pitfalls, follow these URL handling practices throughout your site and marketing stack.
URL Best Practices
| Practice | Why |
|---|---|
| Keep fbclid in URL | Required for attribution, don't strip it |
| Use specific URL patterns | Better custom conversion accuracy |
| Include product IDs in URL | Enables dynamic ads matching |
| Pass order_id to events | Enables deduplication with CAPI |
| Test with Pixel Helper | Verify events fire correctly |
These practices ensure your tracking remains accurate across the entire customer journey. The most critical point is preserving fbclid, as stripping it from URLs is a common mistake that breaks ad attribution entirely.