Meta Pixel extension overview

Meta Pixel is a JavaScript-based analytics tool that allows you to track visitor activity on your website. Visitor actions that you track (called conversions) are sent to Ads Manager where they can be used to measure the effectiveness of your ads, campaigns, conversion funnels, and more.

The Meta Pixel tag extension allows you to leverage Pixel functionalities in your client-side tag libraries. This document covers how to install the extension and use its capabilities in a rule.

Prerequisites

In order to use the extension, you must have a valid Meta account with access to Ads Manager. Specifically, you must create a new Meta Pixel and copy its Pixel ID so the extension can be configured to your account. If you already have an existing Meta Pixel, you can use its ID instead.

It is strongly recommended to use Meta Pixel in combination with the Meta Conversions API to share and send the same events from the client side and server side, respectively, since this may help recover events that were not picked up by Meta Pixel. See the guide on the Meta Conversions API extension for event forwarding for steps on how to integrate it in your server-side implementations. Note that your organization must have access to event forwarding in order to use the server-side extension.

Install the extension

To install the Meta Pixel extension, navigate to the Data Collection UI or Experience Platform UI and select  Tags from the left navigation. From here, select a property to add the extension to, or create a new property instead.

Once you have selected or created the desired property, select  Extensions  in the left navigation, then select the Catalog tab. Search for the Meta Pixel card, then select Install.

The Install button being selected for the Meta Pixel extension in the Data Collection UI.

In the configuration view that appears, you must provide the Pixel ID you copied earlier to link the extension to your account. You can paste the ID directly into the input, or you can select an existing data element instead.

TIP
Using a data element gives you the option to dynamically change the Pixel ID used depending on other factors such as the build environment. See the appendix section on using different Pixel IDs for different environments for more information.

You can also optionally provide an event ID to associate with the extension. This is used to deduplicate identical events between Meta Pixel and the Meta Conversions API. For details, see the section on event deduplication in overview for the Conversions API extension.

When finished, select Save

The Pixel ID provided as a data element in the extension configuration view.

The extension is installed and you can now employ its various actions in your tag rules.

Configure a tag rule rule

Meta Pixel accepts a set of predefined standard events, each with their own contexts and accepted properties. The rule actions provided by the Pixel extension correlate to these event types, allowing you to easily categorize and configure the event being sent to Meta according to its type.

For demonstration purposes, this section shows how to build a rule that sends a page view event to Meta.

Start creating a new tag rule and configure its conditions as desired. When selecting the actions for the rule, select Meta Pixel for the extension, then select Send Page View for the action type.

The Send Page View action type being selected for a rule in the Data Collection UI.

There is no further configuration required for the Send Page View action. Select Keep Changes to add the action to the rule configuration. When you are satisfied with the rule, select Save to Library.

Finally, publish a new tag build to enable the changes to the library.

Confirm that Meta is receiving data

After your updated build has been deployed to your website, you can confirm whether data is being sent as expected by generating some conversion events on your browser and checking if those events appear in Meta Events Manager.

Next steps

This guide covered how to send data to Meta using the Meta Pixel tag extension. If you are planning on also sending server-side events to Meta, you can now proceed to install and configure the Conversions API event forwarding extension.

For more information on tags in Experience Platform, refer to the tags overview.

Appendix: Use different Pixel IDs for different environments id-data-element

If you want to test your implementation in development or staging environments while keeping your production Meta Pixel analytics intact, you can use a data element to dynamically choose an appropriate Pixel ID depending on the environment being used.

You can achieve this by using a Custom Code data element (provided by the Core extension) in combination with the turbine free variable. In the data element’s JavaScript code, use the turbine object to find the current environment stage, then return an appropriate Pixel ID based on the result.

The following example returns a fake production ID exampleProductionKey when used in the production environment, and a different ID exampleTestKey when any other environment is used. When implementing this code, replace each value with your actual production and test Pixel IDs.

return (turbine.environment.stage === "production" ? 'exampleProductionKey' : 'exampleTestKey');
recommendation-more-help
12b4e4a9-5028-4d88-8ce6-64a580811743