Tracking installations from Facebook
You can use AppMetrica to track installations from Facebook ad campaigns. To do this, you need to use tracking links with deeplink.
However, AppMetrica reports show only the number of installations. The number of clicks and conversion to installations are not displayed, because when you click on an ad in Facebook, the user is sent directly to the app store, bypassing the redirect service.
To track installations from Facebook ad campaigns, follow these steps:
Step 1. Prepare your app
- Integrate the AppMetrica SDK. For more information, see Installation and initialization.
- Add deeplink support to your application. For more information, see Android documentation.
- Integrate the latest version of the Facebook SDK. For more information, see Facebook documentation.
- Configure a Facebook regular link and Deferred Deep Link.
- Test the Deferred Deep Link using App Ads Helper in Facebook.
Set up sending information on deeplink to AppMetrica.
Note. Implement redirecting the user to the specific application screen.To get deeplink when installing the app, use the AppLinkData.fetchDeferredAppLinkData(Context, CompletionHandler) method:AppLinkData.fetchDeferredAppLinkData(this, new AppLinkData.CompletionHandler() { @Override public void onDeferredAppLinkDataFetched(AppLinkData appLinkData) { // Sending information about the deeplink to AppMetrica. YandexMetrica.reportReferralUrl(appLinkData.getTargetUri().toString()); // Redirecting via deeplink. ... } }
Copied to clipboardFor already installed application start, use the AppLinkData.createFromActivity(Activity) method. Add the following code to theonCreate
method of the Activity that you are redirect to from Facebook.AppLinkData applinkData = AppLinkData.createFromActivity(this); if (applinkData != null) { YandexMetrica.reportAppOpen(appLinkData.getTargetUri().toString()); }
Copied to clipboard
- Integrate the AppMetrica SDK. For more information, see Installation and initialization.
- Add Universal link support to the app. For more information, see Apple documentation.
- Integrate the latest version of the Facebook SDK. For more information, see Facebook documentation.
- Configure a Facebook regular link and Deferred Deep Link.
Set up sending information on deeplink to AppMetrica.
Note. Implement redirecting the user to the specific application screen.Add the following code to your project:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if (launchOptions[UIApplicationLaunchOptionsURLKey] == nil) { [FBSDKAppLinkUtility fetchDeferredAppLink:^(NSURL *url, NSError *error) { if (error) { NSLog(@"Received error while fetching deferred app link %@", error); } if (url) { // Sending information about the deeplink to AppMetrica. [YMMYandexMetrica reportReferralUrl:url]; [[UIApplication sharedApplication] openURL:url]; } }]; } return YES; }
Copied to clipboard
- Integrate the AppMetrica SDK. For more information, see Installation and initialization.
- Integrate the latest version of the Facebook SDK. For more information, see Facebook documentation.
Add deeplink support to your application:
Addintent-filter
for the activitycom.facebook.unity.FBUnityDeepLinkingActivity
: If the activity doesn't exist, create it:<application> ... <activity android:name="com.facebook.unity.FBUnityDeepLinkingActivity" android:exported="true" > <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:scheme="your-scheme" /> <!-- Replace your-scheme by yours--> </intent-filter> </activity> </application>
Copied to clipboardNote. Make sure that the activity's name isFBUnityDeepLinkingActivity
. Otherwise,FB.GetAppLink
will returnnull
.- Clickand select iOS.
- Select Other and scroll down to the Configuration section.
- Under Supported URL schemes, add your scheme
your-scheme
.
For more information about deeplinks, see the Unity documentation.
Set up sending information on deeplink to AppMetrica.
Note. Implement redirecting the user to the specific application screen.When you install an application using a deeplink:
When you run an earlier installed application using a deeplink:// After init Facebook SDK. FB.Mobile.FetchDeferredAppLinkData(result => { AppMetrica.Instance.ReportReferralUrl(result.TargetUrl); // Process app link data. });
Copied to clipboard
You need to callFB.GetAppLink(result => { AppMetrica.Instance.ReportAppOpen(result.TargetUrl); // Process app link data FB.ClearAppLink(); });
Copied to clipboardFB.ClearAppLink()
so that you don't have to track the deeplink again (Android only).
Step 2. Create a tracker
In the AppMetrica interface, go to Trackers.
- In the top-left corner, click Create a tracker.
- In the Campaign details block fill in all fields:
- This is remarketing campaign — Flag indicating that the tracker is being created for a remarketing campaign.
For more information, see Creating a remarketing tracker.
- Title — Enter the name of the tracker. After being created, the tracker is available in the list with the specified name.
- Application — Select the application the tracker is being created for.
- Partner — Select Facebook.
- In the Destination link settings block, select the platform and specify the created URL scheme for deeplink.
- Save the created tracker.
- Copy the link from the Tracking Deeplink field.
Step 3. Create a Facebook advertising campaign
When creating an ad campaign, use the tracking deeplink that was created in the previous step.
For more information, see Adding Deeplink to Ads Facebook documentation.