How to preview and validate Facebook Pixel events
These CLI commands let you inspect, from the command line, the exact Facebook Pixel event your store would send for a given product, category search, or order - without opening a browser or placing a real order. Use them to troubleshoot missing or incorrect data before it reaches Meta Events Manager, or as an automated check after a deployment.
Preview an event
php -f bin/magento mirasvit:fbmarketing:preview --event=<event> [options]
Prints the Facebook Pixel event as JSON, built the same way the storefront and Conversions API build it.
--event- one ofview_item,search,purchase(required)--sku- product SKU, forview_itemandpurchase--category- category ID, forsearch--query- search term, forsearch--order- order ID to use in thepurchaseevent (defaults toORDER-1001)
Examples:
php -f bin/magento mirasvit:fbmarketing:preview --event=view_item --sku=24-MB01
php -f bin/magento mirasvit:fbmarketing:preview --event=search --category=20 --query="running shoes"
php -f bin/magento mirasvit:fbmarketing:preview --event=purchase --sku=24-MB01 --order=100000123
Validate events
php -f bin/magento mirasvit:fbmarketing:validate [--sku=<sku>] [--category=<id>] [--query=<text>] [--format=text|json]
Builds the Pixel events for the given product and/or category and checks them against Meta's expected event structure, printing any problems found. The command exits with a non-zero status code if a violation is found, so it can be used in deployment or monitoring scripts.
--sku- validates theViewContentandPurchaseevents for this product--category- validates theSearchevent over this category--query- search term used for theSearchevent (defaults totest)--format-text(default, human-readable) orjson
Provide at least one of --sku or --category. A Facebook pixel ID must be configured under
Facebook pixel - otherwise the command
reports that Facebook Marketing is not set up and stops.
Example:
php -f bin/magento mirasvit:fbmarketing:validate --sku=24-MB01 --category=20 --format=json