Skip to content

Allow configuring the cookie domain for _fbp/_fbc #29

Description

@loevgaard

Problem

Meta's pixel writes _fbp and _fbc on the registrable domain (for example .example.com) and encodes the level it used in the second segment of the value: fb.1. means example.com, fb.2. means www.example.com, fb.0. means com.

StoreFbpSubscriber and StoreFbcSubscriber create host-only cookies (no domain argument to Cookie::create()), while the SDK value objects default the subdomain index to 1. On a site served from www.example.com the result is a host-only cookie whose value claims to be a domain cookie. When a visitor moves between www.example.com, example.com or a checkout subdomain, the browser presents different cookies, and the browser pixel may write its own domain cookie next to the server one, producing two _fbp values for one person.

Suggested fix

Add configuration:

setono_meta_conversions_api:
    cookies:
        domain: null          # e.g. '.example.com'; null = host-only
        lifetime: '+90 days'

Set the subdomain index on generated Fbp/Fbc values accordingly (withSubdomainIndex(2) for host-only on a www. host, 1 when a domain cookie is configured). Meta's capi-param-builder ships an ETLDPlus1Resolver that shows the intended logic if auto-detection is preferred over configuration.

Related: #28.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions