August 15, 2019
April 30, 2019
We recently revamped our official Facebook pixel plugin for WordPress, Drupal, and Joomla. The Facebook pixel plugin, available for download, allows website owners to easily manage the Facebook pixel on their website.
Website owners provide their own Facebook pixel in the admin page and the Facebook pixel with the PageView event is fired on the website by default. Using the following settings, a website marketer can use the signal collected to build the website custom audience and enable their retargeting campaigns.
With the new structure of the Facebook pixel plugin, other plugin developers can now easily build on top of our plugin to fire the lower-funnel standard event or custom event on the website. They don't need to manage Facebook pixel settings in their own respective plugins. This allows website marketers to create campaigns targeted to further down funnel people.
We use WordPress as an example, while the other two platforms (Drupal and Joomla) use similar logic. The samples for each are provided in the open-sourced Github:
Under the new plugin folder structure lives a folder (named “integration” in Wordpress or “integrations” in Drupal and Joomla). This folder contains the integrated plugin class; for example, Wordpress
The integrated plugin class extends the
FacebookWordpressIntegrationBase class (similar to all other platform). As a developer, you must define two constants:
PLUGIN_FILE— Used for the Facebook pixel plugin to check whether your plugin exists. If it is not, this integration class is not processed.
TRACKING_NAME— Used for the Facebook to track the integration. This is fired at the pixel initiation code at the page load as follows.
Example — Easy Digital Downloads
Additionally, you must specify the
injectPixelCode function, which is where the pixel code is being fired. Inside the function, you can specify their hook through the
add_action WordPress function call or our pre-defined
addPixelFireForHook function call from the parent class. The pre-defined
addPixelFireForHook function is used to simplify the implementation where you just have to specify one Hook handling function.
If you're using the
add_action Wordpress function
add_actionWordpress frunction call with the
If you're using our
addPixelFireForHook function, specify the hook name, classname, and its
handle function. By default, the pixel is fired at
handle function is triggered when the page loads.
We provide the
We predefined a list of functions for all standard events that Facebook supports. To use the function, specify the
param (default is an empty array, the parameter will be Json encoded when it returns), the
TRACKING_NAME (reuse the class constant), and script tag option (default is
true, meaning the code snippet is encapsulated by the
Example — Using the
FacebookPixel class to return checkout code snippet
There's a hack in the
We make this design change such that you can now focus on your own plugin development, while you can also rely on our Official Facebook pixel plugin to fetch and fire the Facebook pixel accordingly for your own use case. For example, for an e-commerce website plugin, you can focus on improving the e-commerce feature instead of needing to put the Facebook pixel code snippet everywhere in your plugin. Further, you can reply on Official Facebook pixel plugin for handling the pixel and its code snippet.
We look forward to your integration!