Back to News for Developers

Mobile DPA

July 13, 2015ByCraig Kochis

As mentioned in a previous blog post, Dynamic Product Ads allow advertisers to target ads to customers using their existing catalog. One of the great things about DPA is the ability to reach users across a range of devices, whether that’s browsing your website or interacting with your app.

Here we’re going to cover setting up mobile app events for Dynamic Product Ads, and how to properly configure the product catalog to enable deep linking from your dynamic product ads.

Setting up Deep Links in Product Feed

This step is only required if you wish to enable deep linking from your dynamic product ads into your app.

By providing deep links in your product feed, users who interact with your ad on Facebook can be sent directly into a specific location of your app if deep linking has been set up. For instance, clicking a dynamic product ad from the Facebook mobile app would open that product directly in your mobile app.

To setup the deep links for your dynamic ads, follow the specifications listed on the Product Catalog set up page.

Setup Mobile App Events

Similar to how the Facebook pixel events (ViewContent, AddToCart, Purchase) are tracked on the web, we can track the same events interactions in a mobile app. Once you’ve setup your Facebook App and installed the appropriate Facebook SDK, you’re ready to start sending app events.

iOS SDK: https://developers.facebook.com/docs/ios

Android SDK: https://developers.facebook.com/docs/android

The same three required events (ViewContent, AddToCart, Purchase) that are sent from the Facebook pixel need to also be sent from the app.

iOS Event Android Event Web Equivalent

FBSDKAppEventNameViewedContent

AppEventsConstants:: EVENT_NAME_VIEWED_CONTENT

ViewContent

FBSDKAppEventNameAddedToCart

AppEventsConstants:: EVENT_NAME_ADDED_TO_CART

AddToCart

[FBSDKAppEvents logPurchase:(double) currency:(NSString *) parameters:(NSDictionary *)];

AppEventsConstants:: EVENT_NAME_PURCHASED

Purchase

Below is an example of a ViewContent event being fired when someone views a product within an app.

- (void)viewDidLoad {
[FBSDKAppEvents logEvent:FBSDKAppEventNameViewedContent
valueToSum: 120.00
parameters:@{ FBSDKAppEventParameterNameCurrency    : @"USD",
FBSDKAppEventParameterNameContentType : @"product",
FBSDKAppEventParameterNameContentID   : @"1234" }];

[super viewDidLoad];
...
Bundle parameters = new Bundle();
parameters.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "USD");
parameters.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, "product");
parameters.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, "1234");

logger.logEvent(AppEventsConstants.EVENT_NAME_VIEWED_CONTENT,
120.00,
parameters);

The product ID field can also take a JSON array of values for when an event should occur for multiple products, such as with the Purchase event.

- (void)viewDidLoad {
[FBSDKAppEvents logEvent:logPurchase
valueToSum: 180.00
parameters:@{ FBSDKAppEventParameterNameCurrency    : @"USD",
FBSDKAppEventParameterNameContentType : @"product",
FBSDKAppEventParameterNameContentID   : @"['1234', '5678']" }];

[super viewDidLoad];
...
Bundle parameters = new Bundle();
parameters.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "USD");
parameters.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, "product");
parameters.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, "['1234', '5678']");

logger.logEvent(AppEventsConstants.EVENT_NAME_PURCHASED,
180.00,
parameters);

Learn more about iOS and Android app events.

To ensure your app events are being sent correctly, you can check your recent events in Facebook Analytics for Apps.

Fallback to Web vs. Appstore

If you're creating Dynamic Product Ads with deeplink support, you have the ability to specify the fallback behavior if the user does not have the app installed on their phone. If deep links are present in your product feed but the user does not have the app installed, the default behavior will send users to the web url for the product in the ad.

Since the objective of remarketing is to increase catalog sales, it's recommended to fallback to sending users to product pages, rather than app installs. This is why we default to web urls, though you can specify the fallback behavior for more control.

Deep Link Fallback Behavior

The fallback behavior for someone who does not have the app installed can be set using the applink_treatment field when creating a Dynamic Product Ad.

The following fallback options are available:

Field Name Description

web_only

Always send the user to the given web URL. This will override any deeplinks in the feed.

deeplink_with_web_fallback

If the app is installed on the user's phone and we have corresponding deep link information, send the user to the app. If one of these conditions is not met, send them to the website url for product.

deeplink_with_appstore_fallback

If the app is installed on the user's phone and we have corresponding deep link information, send the user to the app. If the app is not installed, send them to the app store for the app.

Aggregation of Web and App Events

One of the major advantages of advertising on the Facebook platform is the ability to measure conversions across devices. If a customer is shown an ad on their mobile device, but later makes the purchase from desktop, we can still attribute the conversion to that ad.

This cross-device conversion measurement also works with DPA retargeting and conversions as well. By sending the same product events from your mobile device as well as website, you will be able to retarget users based on the products they've seen on mobile, web, or both. The conversions for these ads will also be attributed to the user, regardless of the device they purchase with.

Measure Off-Facebook Events in Your Ads

In order to properly measure conversion events from both your website and mobile app, make sure any DPA ads have the correct tracking specs set for tracking both events.

Event Tracking Spec

offsite_conversion

{ 'action.type': 'offsite_conversion', 'fb_pixel': FB_PIXEL_ID }

app_custom_event

{'action.type':'app_custom_event','application':APP_ID}

mobile_app_install

{'action.type':'mobile_app_install','application':APP_ID}

This will ensure any events occuring as the result of a Dynamic Product Ad will be tracked accordingly, regardless of if the user is viewing the website, or within an app.

To set these tracking specs when creating an ad:

curl \
-F "tracking_spec=[{'action.type':['app_custom_event'],'application': ['<APP_ID>']},{'action.type': ['offsite_conversion'], 'offsite_pixel': ['<FB_PIXEL_ID>']}, {'action.type': ['mobile_app_install'], 'application': ['<APP_ID>']}" \ 
-F "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/<AD_GROUP_ID>"

Cross Device Ad Reports

We can see how are ads are performing across devices by using the Ad Insights API.

For instance, lets say we wanted to see the conversion breakdown by device and type, we can leverage the tracking specs we set up earlier to generate our reports. We can get this data from the ads reports api using the following call:

curl -G \
-d "date_preset=last_7_days" \
-d "fields=account_id,actions,impressions,placement,impression_device" \
-d "action_breakdowns=action_type,action_device" \
-d "access_token=<ACCESS_TOKEN>" \
https://graph.facebook.com/v2.4/<AD_ACCOUNT_ID>/insights

Which would return something similar to:

{
"data": [
{
"account_id": "1234",
"actions": [
{
"action_device": "other",
"action_type": "app_custom_event.fb_mobile_purchase",
"value": 128
},
{
"action_device": "iphone",
"action_type": "app_custom_event.fb_mobile_purchase",
"value": 2845
},
{
"action_device": "android_smartphone",
"action_type": "app_custom_event.fb_mobile_purchase",
"value": 26
},
{
"action_device": "desktop",
"action_type": "offsite_conversion.checkout",
"value": 70
},
{
"action_device": "iphone",
"action_type": "mobile_app_install",
"value": 77
},
{
"action_device": "android_smartphone",
"action_type": "mobile_app_install",
"value": 1
}
],
"impressions": "171406",
"placement": "mobile_feed",
"impression_device": "iphone",
"date_start": "2015-07-01",
"date_stop": "2015-07-08"
}
]
}

Read more about ads insights


Tags: