:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(cdp): send the $fbp browser ID to Meta Ads (#99081)
Harley Alexandere61e36aba60b
diff --git a/frontend/src/taxonomy/core-filter-definitions-by-group.json b/frontend/src/taxonomy/core-filter-definitions-by-group.jsonindex c3c4a4f73f6c..fa819b0e187b 100644--- a/frontend/src/taxonomy/core-filter-definitions-by-group.json+++ b/frontend/src/taxonomy/core-filter-definitions-by-group.json@@ -6351,6 +6351,14 @@"label": "Facebook click ID (fbc)","type": "String"},+ "$fbp": {+ "description": "The Facebook browser ID that Meta's Conversions API uses to match a conversion to a browser, read from the `_fbp` cookie the Meta pixel sets.",+ "examples": [+ "fb.1.1735689600000.1098115397"+ ],+ "label": "Facebook browser ID (fbp)",+ "type": "String"+ },"$feature_flag": {"description": "The key of the feature flag, sent on \"Feature flag called\", \"Experiment exposure\", and \"Feature enrollment\" events. To find other events where a flag was active, use \"Active feature flags\".","examples": [diff --git a/nodejs/src/cdp/templates/_destinations/meta_ads/meta.template.test.ts b/nodejs/src/cdp/templates/_destinations/meta_ads/meta.template.test.tsindex 717afd7ba4e0..2f25d7608641 100644--- a/nodejs/src/cdp/templates/_destinations/meta_ads/meta.template.test.ts+++ b/nodejs/src/cdp/templates/_destinations/meta_ads/meta.template.test.ts@@ -236,6 +236,39 @@ describe('meta ads template', () => {})})+ describe('fbp browser ID', () => {+ it.each([+ {+ name: 'sends the $fbp the SDK read from the pixel cookie',+ person: { $fbp: 'fb.1.1735689600000.1098115397' },+ expected: 'fb.1.1735689600000.1098115397',+ },+ {+ name: 'prefers the fbp the site stores itself',+ person: { fbp: 'fb.1.1735689600000.site-owned', $fbp: 'fb.1.1735689600000.1098115397' },+ expected: 'fb.1.1735689600000.site-owned',+ },+ {+ name: 'sends nothing when the person holds no fbp',+ person: {},+ expected: undefined,+ },+ ])('$name', async ({ person, expected }) => {+ const response = await tester.invokeMapping(+ 'Page Viewed',+ { accessToken: 'access-token', pixelId: 'pixel-id' },+ createAdDestinationPayload({+ event: { event: '$pageview', properties: {} },+ person: { properties: person },+ })+ )++ expect(response.error).toBeUndefined()+ const body = parseJSON((response.invocation.queueParameters as { body: string }).body)+ expect(body.data[0].user_data.fbp).toEqual(expected)+ })+ })+it('surfaces error responses', async () => {const response = await tester.invokeMapping('Order Completed',diff --git a/nodejs/src/cdp/templates/_destinations/meta_ads/meta.template.ts b/nodejs/src/cdp/templates/_destinations/meta_ads/meta.template.tsindex 3941c944e987..e7172b591556 100644--- a/nodejs/src/cdp/templates/_destinations/meta_ads/meta.template.ts+++ b/nodejs/src/cdp/templates/_destinations/meta_ads/meta.template.ts@@ -48,8 +48,9 @@ const NINETY_DAYS_MS = 90 * 24 * 60 * 60 * 1000const CLOCK_SKEW_TOLERANCE_MS = 5 * 60 * 1000// Meta's _fbp cookie value, `fb.<subdomainIndex>.<creationTimeMs>.<randomNumber>`. It identifies a-// browser rather than a click, so PostHog cannot derive it and this reads a value the site mints.-const fbp = "{person.properties.fbp ?? ''}"+// browser rather than a click, so PostHog cannot derive it. Sources in order: a value the site+// stores itself, and the $fbp the SDK reads from the cookie the pixel mints.+const fbp = "{person.properties.fbp ?? person.properties.$fbp ?? ''}"export const template: HogFunctionTemplate = {free: false,diff --git a/nodejs/tests/fixtures/hog-bytecode/837d6adc2c9edf5b6e593a960faddc040c7d84a40a30ae6993c46b26ad4fe050.json b/nodejs/tests/fixtures/hog-bytecode/837d6adc2c9edf5b6e593a960faddc040c7d84a40a30ae6993c46b26ad4fe050.jsonnew file mode 100644index 000000000000..866cede49f96--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/837d6adc2c9edf5b6e593a960faddc040c7d84a40a30ae6993c46b26ad4fe050.json@@ -0,0 +1 @@+["_H",1,32,"fbp",32,"properties",32,"person",1,3,47,9,35,32,"$fbp",32,"properties",32,"person",1,3,47,3,35,32,"",38]diff --git a/posthog/taxonomy/taxonomy.py b/posthog/taxonomy/taxonomy.pyindex df0519246a9c..2d2358643516 100644--- a/posthog/taxonomy/taxonomy.py+++ b/posthog/taxonomy/taxonomy.py@@ -3630,6 +3630,12 @@ CORE_FILTER_DEFINITIONS_BY_GROUP: dict[str, dict[str, CoreFilterDefinition]] = {"examples": ["fb.1.1735689600000.IwAR2xY9zAbCdEf"],"type": "String",},+ "$fbp": {+ "label": "Facebook browser ID (fbp)",+ "description": "The Facebook browser ID that Meta's Conversions API uses to match a conversion to a browser, read from the `_fbp` cookie the Meta pixel sets.",+ "examples": ["fb.1.1735689600000.1098115397"],+ "type": "String",+ },},"session_properties": {"$session_duration": {