Skip to main content

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 of view_item, search, purchase (required)
  • --sku - product SKU, for view_item and purchase
  • --category - category ID, for search
  • --query - search term, for search
  • --order - order ID to use in the purchase event (defaults to ORDER-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 the ViewContent and Purchase events for this product
  • --category - validates the Search event over this category
  • --query - search term used for the Search event (defaults to test)
  • --format - text (default, human-readable) or json

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