How to use multiple pixel ids in one react native app for tracking?

147 Views Asked by At

I have a app in react native. I want to track facebook pixel events on 2 different pixel accounts. I am using react-native-fbsdk-next

I have tried adding Settings.setAppID('PIXEL_1'); Settings.setAppID('PIXEL_2'); but not working. As default pixel configuration is been added in android manifest and info.plist:

AndroidManifest.xml

 <application ...>
    <meta-data android:name="com.facebook.sdk.ClientToken"       android:value="@string/facebook_client_token"/>
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
...
...
</application>

Info.plist

<key>FacebookAppID</key>
<string>PIXEL_APP_ID</string>
<key>FacebookClientToken</key>
<string>PIXEL_CLIENT_TOKEN</string>
1

There are 1 best solutions below

2
On

You can define the Facebook id programmatically. So you do not need to setup the facebook id manifest or info.plist file.

Android

FacebookSdk.setApplicationId("123456789");

iOS

[FBSettings setDefaultAppID: @"123456789"];

At last, when you need to change it you have to create a native bridge to update that facebook id. Please use react-native- document. link