Meta pixel integration
A Meta pixel is a web-only analytics tool from Meta. As of v4.34 of the Facebook SDK, you can track pixel events in an app's webview. You can also convert Meta Pixel events into Meta App events. To do this, use Hybrid Mobile App Events.
It is also now possible to use a Meta pixel with the Adjust SDK, without integrating the Facebook SDK.
Before you begin
Availability
You need to download and set up the Adjust SDK for your platform. Follow the instructions linked below to get started.
Example apps
Meta integration
Meta App ID
To start working with Meta pixels, follow the steps below:
Meta pixel configuration
Follow Meta's guide on how to integrate the Meta pixel. The Javascript code should look something like this:
<!-- Meta Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
...
fbq('init', <YOUR_PIXEL_ID>);
fbq('track', 'PageView');
</script>
...
<!-- End Meta Pixel Code -->
Next, update your Meta pixel code. You can find the instructions in the Hybrid Mobile App Events guide under Update Your Pixel.
fbq('init', <YOUR_PIXEL_ID>);
fbq('set', 'mobileBridge', <YOUR_PIXEL_ID>, <YOUR_FB_APP_ID>);
init
and then set
immediately afterwards. The snippet provided by Meta contains a track
method. You can use this method to track a page view event right after you call the init
method. To track the view event, you need to call set
between init
and track
.
Adjust SDK integration
Augment the web view
Event name registration
The Adjust web bridge SDK translates Meta pixel events into Adjust events.
To use this feature, you need to map Meta pixels to specific Adjust events. You can also configure a default Adjust event token. To use a default token, you need to add the token before starting the Adjust SDK and tracking any pixel event. This includes the copy-pasted fbq('track', 'PageView');
event from the Meta pixel configuration.
To map events, call the addFbPixelMapping
method on your config instance. Use the Meta event name and Adjust event token as parameters. You need to call this before you initialize the Adjust SDK.
adjustConfig.addFbPixelMapping('fb_mobile_search', adjustEventTokenForSearch);
adjustConfig.addFbPixelMapping('fb_mobile_purchase', adjustEventTokenForPurchase);
fbq('track', 'Search')
and fbq('track', 'Purchase')
. Adjust does not have access to the full map between the Facebook SDK and Javascript events.
The Adjust SDK will log warnings if it cannot find a default event token for certain events.
There is not a default event token configured or a mapping found for event named: 'fb_mobile_search'. It won't be tracked as an adjust event
You can also set a default Adjust event if you do not have mapping configured. To do this, call adjustConfig.setFbPixelDefaultEventToken(defaultEventToken);
before initializing the Adjust SDK.