Facebook Pixel (Meta Pixel)
Facebook Pixel (Meta Pixel) for Sylius 2: browser tracking and server-side Conversions API (CAPI) with event deduplication, per-channel settings and optional Klaro consent gating.
Facebook Pixel (Meta Pixel)
This documentation always describes the current state of the plugin.
Live Demo: Try this and other plugins live — no installation, no risk: demo.markus-michalski.net
Overview
Facebook Pixel (Meta Pixel) integration for Sylius 2 shops: browser-side e-commerce event tracking plus the server-side Meta Conversions API (CAPI), with automatic event deduplication, per-channel settings and optional Klaro consent gating. Sylius equivalent of the Shopware plugin mmd/sw67-facebook-pixel.
This plugin sends data to Meta (Facebook). You must disclose this in your shop's privacy policy and cookie banner. Details: Privacy.
Server-side (CAPI) events are fail closed by default: without verifiable consent evidence, nothing is sent. See Configuration.
graph LR
A["Twig hook"] --> B["Meta Pixel in the browser"]
A --> C["PixelEventDispatched"]
C --> D{"CAPI enabled and consent ok?"}
D -->|"Yes"| E["Messenger: SendCapiEventMessage"]
D -->|"No"| F["Nothing sent"]
E --> G["Meta Conversions API"]
B --> H["Meta Events Manager"]
G --> H
I["Shop API"] --> J["Headless client"]
Documentation
| Page | Content |
|---|---|
| Installation and Operation | Installation, update, uninstall |
| Configuration | Settings per channel, Conversions API setup, practical examples |
| Storefront Integration | Twig hooks, event deduplication, consent gating, AddToCart timing |
| Shop API / Headless | Endpoint, response fields, boundary to the CAPI |
| Extending | Custom consent-evidence providers, the PixelEventDispatched event, access-token encryption |
| Privacy | Which data goes to Meta and when, hashing, consent |
| Troubleshooting and FAQ | Common problems, known limitations, frequently asked questions |
| Technical Details | Flow, plugin structure, entity, messaging |
Features
| Feature | Description |
|---|---|
| Six events | PageView, ViewContent, ViewCategory (custom event), AddToCart, InitiateCheckout, Purchase |
| Meta Conversions API | Asynchronous server-side mirror for any of the six events (selectable per channel); email and phone number are SHA-256-hashed |
| Event deduplication | Browser and server share one event_id per action |
| Per channel | Pixel ID, event selection, gross/net prices and CAPI settings apply per channel |
| Fail-closed CAPI consent | No verifiable consent evidence, no server-side event (default) |
| Klaro integration | Optional, detected at runtime: gates the browser scripts and provides the CAPI consent evidence |
| Dual-mode | The settings a headless client needs are readable through the Shop API |
| Encrypted access token | The Conversions API token is never stored in plaintext |
Requirements
| Requirement | Version | Notes |
|---|---|---|
| PHP | ^8.3 | |
| Sylius | ^2.2 | |
| Symfony | ^7.4 | |
| Database | MySQL 8 or MariaDB | The migrations use the portable Doctrine Schema API |
| Meta Pixel ID | - | From Meta Events Manager; a Conversions API access token is optional |
License
Commercial license: one license covers one Sylius installation (all channels plus its development and staging environments). Redistribution is not allowed; updates are included for 12 months from purchase.
Support
For questions about the license, technical questions or bugs, reach me at support@markus-michalski.net.