Facebook Pixel
- Installing the Magento 2 Facebook Pixel extension
- Set up cron
- Uninstalling the Magento 2 Facebook Pixel extension
- Extension Compatibility
- Introducing to Magento 2 Facebook Pixel
- Using Magento 2 Facebook Pixel
Installing the Magento 2 Facebook Pixel extension
Command Line Installation
-
Backup your web directory and store database
-
Download the Facebook Pixel installation package
-
Upload contents of the Facebook Pixel installation package to your store root directory
-
In SSH console of your server navigate to your store root folder:
cd path_to_the_store_root_folder
Run the following command:
php bin/magento module:enable Aheadworks_FacebookPixel
then:
php bin/magento setup:upgrade
after:
php bin/magento setup:static-content:deploy -f
-
Flush store cache; log out from the backend and log in again
|
Make sure the installation is done from the FTP administrator account. Otherwise, set 775 permissions to the store root directory after the extension is deployed. |
Composer Installation
If you are installing an extension from Aheadworks for the first time, you need to add our composer repository to your Magento store:
1. Login to your ssh console and navigate to your store folder:
cd path_to_the_store_root_folder
Run the following commands:
|
composer config repositories.aheadworks composer https://dist.aheadworks.com/ |
After the command was executed successfully, you can use the composer to install the extension.
To install the extension:
2. Login to your ssh console and navigate to your store folder:
cd path_to_the_store_root_folder
3. Run the following command to install the latest version of the extension:
composer require aheadworks/module-facebook-pixel
if you need to install a specific version, run this command:
composer require aheadworks/module-facebook-pixel<version>
| Specify the version of the extension in <version> |
When prompted, enter Public Key (Username) and Private Key (Password):
Both Public Key (Username) and Private Key (Password) can be found in My Projects and Licenses in your personal account on our site:
To upgrade the extension:
To update or upgrade an extension:
Download the updated extension file. Take note of the module-name and version. Export the contents to your Magento root.
If a composer package exists for the extension, run one of the following.
Update per module name:
composer update aheadworks/module-facebook-pixel
Updater per version:
composer require aheadworks/module-facebook-pixel:<version>
Run the following commands to upgrade, deploy, and clean the cache.
php bin/magento setup:upgrade --keep-generated
php bin/magento setup:static-content:deploy
php bin/magento cache:clean
Set up cron
If you have already configured cron jobs for your Magento installation then you can skip this step. Read the following instructions on setting cron job for your Magento store: Magento user guide.-
Generally, it would be enough to run in SSH console of your server:
crontab -e
And insert the following line:
*/3 * * * * php -c <ini-file-path> <your Magento install dir>/bin/magento cron:run
*/3 * * * * php -c <ini-file-path> <your Magento install dir>/update/cron.php
*/3 * * * * php -c <ini-file-path> <your Magento install dir>/bin/magento setup:cron:run
Remember to confirm the Save request when exiting the installation.
Uninstalling the Magento 2 Facebook Pixel extension
Since Magento introduced declarative Database you need to be very careful when uninstalling or disabling the module.
|
NOTE: Please be very careful when uninstalling/disabling this module. This module uses a declarative DB scheme. Once the module is uninstalled its DB tables will be lost. |
Manual Removal
1. Disable the module by executing the following commands:
php bin/magento module:disable Aheadworks_FacebookPixel
php bin/magento setup:upgrade
2. Remove the extension files from the following folder:
app/code/Aheadworks/FacebookPixel
Automatic Removal (via Composer)
1. Disable the module by executing the following commands:
php bin/magento module:uninstall Aheadworks_FacebookPixel
Extension Compatibility
|
Module Version |
Magento Version |
|
As of version 1.0.0 |
2.4.6 - 2.4.8 |
Introducing to Magento 2 Facebook Pixel
Extension Overview
The Facebook Pixel Tracking for Magento 2 extension provides a seamless, code-free integration between your Magento storefront and Meta Events Manager. Designed for modern data-driven marketing, the module enables store owners to effortlessly deploy the Meta (Facebook) Pixel across multiple storefronts to track user interactions, optimize ad spend, and build highly accurate retargeting audiences.
With full support for both browser-side tracking and server-to-server data transmission via the Conversions API (CAPI), the extension bypasses ad-blockers and privacy restrictions to prevent data loss. The entire module is managed natively within the Magento Admin panel, giving merchants complete control over conversion tracking without editing theme files or executing CLI commands.
Key Features
-
Integrate Meta Pixel tracking seamlessly into your storefront without modifying any source code.
-
Deploy multiple tracking profiles simultaneously to manage unique Pixel IDs across different store views.
-
Capture standard e-commerce milestones automatically to track user behavior from view to purchase.
-
Safeguard data against ad-blockers and privacy restrictions by routing server events via Conversions API.
-
Maximize ad attribution accuracy and expand remarketing audiences using secure Advanced Matching.
-
Manage all tracking criteria natively inside the admin panel with complete autonomy and zero CLI commands.
Using Magento 2 Facebook Pixel
Extension Configuration
To configure the global display settings for the module, navigate to Stores > Settings > Configuration > AHEADWORKS EXTENSIONS > Facebook Pixel.
General Settings
The General Settings section allows you to activate the extension, configure local data logging for testing, and inject your tracking pixel code directly into the storefront pages.
-
Enable Meta Pixel – Enables or disables the extension functionality for the selected store view.
-
Yes – Activates Meta Pixel tracking across the storefront.
-
No – Completely deactivates the extension and stops data collection.
-
Enable Pixel Events Logging – Controls the recording of pixel event data for debugging purposes.
-
Yes – Records pixel payload data to a local log file on the server. The log data is stored on your server at the following path: var/log/aw_meta_pixel.log
-
No – Disables event logging.
-
Custom Script – A dedicated text area to input your tracking scripts.
-
Paste your primary Meta Pixel base code or any additional tracking snippets into this field. The extension automatically injects this content into the <head> section of every storefront page.
Meta Pixels Management
The Meta Pixels grid serves as the central control panel where you can view, create, and manage your tracking profiles for different store views.
To open the grid, navigate to MARKETING > Meta Pixel Tracking by Aheadworks > Meta Pixels.
Managing Pixel Profiles
The grid displays all configured pixels and contains the following columns:
-
ID – The internal identifier assigned automatically to each profile.
-
Pixel ID – The unique dataset ID copied from your Meta Events Manager.
-
Status – Shows whether the current pixel profile is actively tracking data (Enabled) or paused (Disabled).
-
Store View – Displays the specific website, store, or store view scope where the pixel code is injected.
-
Action – Contains the Edit link to modify profile settings, event rules, or API tokens.
Mass Actions
To quickly manage multiple tracking profiles at once, select the checkboxes next to the required items, click the Actions dropdown menu in the top-left corner, and choose one of the available operations:
-
Delete – Permanently removes the selected pixel configurations from the system.
-
Change Status – Batch switches the status of selected profiles to Enabled or Disabled without opening each setting individually.
Creating a New Meta Pixel
To create and configure a new tracking profile, click the Add New Meta Pixel button in the top-right corner of the grid. In the opened General settings section, define the core parameters for the pixel integration, catalog matching, and data transmission.
-
Dataset ID (Required) – The unique identifier of your pixel copied from the Meta Events Manager. The system uses this ID to route storefront events directly to your Meta advertising account.
|
Where to find your Dataset ID: Log in to your Meta Events Manager. Navigate to the Data Sources tab on the left menu, select your pixel, and copy the ID from the overview dashboard. For detailed instructions, refer to the official Meta Pixel Setup Guide. |
- Enable Tracking – A toggle switch to quickly activate or pause data collection for the current profile.
-
Yes – Active tracking and event transmission to Meta.
-
No – Tracking is temporarily suspended.
-
|
NOTE: If no Pixel ID is enabled, no Facebook events will be fired. |
-
Store View – Defines the configuration scope for the pixel. You can select All Store Views to apply a single pixel across a multi-store setup, or assign the profile to a specific website, store, or individual store view.
-
Product Identifier – Determines which Magento product attribute is transmitted to Meta as the
content_idsparameter. -
SKU – Sends the product stock keeping unit. Select this option if your Facebook Product Feed (catalog for dynamic ads) uses SKUs as the product identifiers.
-
Product ID – Sends the internal database entity ID assigned by Magento.
-
Send Customer ID – Controls the transmission of user identifiers to match user sessions more accurately.
-
Yes – Appends session IDs for guest shoppers and unique customer IDs for logged-in users to the data layer.
-
Enable Advanced Matching – Enables Meta's Advanced Matching functionality to improve ad performance and attribution.
-
Yes – The extension automatically passes secure, hashed customer data (Email, Phone Number, First and Last Name, City, State, and ZIP Code) during conversion actions. This increases the match rate for retargeting audiences and improves ad attribution by accurately linking store visitors to their Meta accounts.
Conversions API Settings
The Conversions API settings section allows you to configure server-side tracking. By combining standard browser pixel tracking with server-to-server events, you bypass browser restrictions, ad-blockers, and connectivity issues, ensuring maximum data accuracy for your Meta marketing campaigns.
-
Enable Conversion API – Toggles server-side tracking functionality for the current profile.
-
Yes – Activates the Conversions API (CAPI). The extension will send tracking events directly from your Magento server to Meta's servers alongside the standard browser events. Meta automatically deduplicates these duplicate signals using event IDs.
-
No – Deactivates server-side event transmission, relying solely on standard browser-based pixel tracking.
-
Access Token – A secure authentication string required to authorize server-to-server data transmission. Paste your unique permanent access token into this field.
|
Where to find it: Log in to your Meta Events Manager, navigate to the Settings tab of your targeted dataset, scroll down to the Conversions API section, and click the Generate access token link. |
Tracked Events
The Tracked Events section allows you to manage specific conversion goals and e-commerce milestones. Use the toggle switches to choose exactly which store visitor actions are captured and reported to Meta.
-
Product Search – Tracks when a visitor utilizes the storefront search bar.
-
Meta event name: Search
-
Category Viewed – Tracks when a customer browses a catalog category or landing page.
-
Meta event name: ViewCategory
-
Product Viewed – Tracks when a user opens a product detail page (PDP) to view a specific item.
-
Meta event name: ViewContent
-
Product Added To Wishlist – Tracks when a shopper adds an item to their personal wishlist.
-
Meta event name: AddToWishlist
-
Product Added To Cart – Tracks when a customer clicks the add-to-cart button from a product page or category grid.
-
Meta event name: AddToCart
-
Checkout Started – Tracks when a customer proceeds to the checkout page to begin the order placement process.
-
Meta event name: InitiateCheckout
-
Purchase Completed – Tracks successful transactions when a customer reaches the order confirmation or "Thank You" page.
-
Meta event name: Purchase
-
Customer Registration Completed – Tracks new user account creations on the storefront.
-
Meta event name: CompleteRegistration
-
Customer Subscribed to Newsletter – Tracks when a visitor signs up for store newsletter updates or marketing emails.
-
Meta event name: Subscribe