Dynamic Ads for Mobile Apps

Set up dynamic ads on mobile with Facebook SDKs. You should incorporate deep linking and deferred deep linking into your app to provide people using your app with the best experience possible:

Step 1: Set Up Facebook Mobile SDK for iOS/Android

Integrate Facebook SDK for iOS or Android. See Facebook SDK for iOS or Facebook SDK for Android.

Step 2: Set Up Mobile App Events

On the web, use Facebook Pixel events such as ViewContent for tracking events interactions. On mobile we can track the same events with App Events.

You must send the same three required events from your app as you do from Facebook pixel. These are: ViewContent, AddToCart, Purchase. Dynamic Ads requires these events to work correctly.

iOS Event Android Event Web Equivalent







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



For example,ViewContent event fires when someone views a product in an app:

[FBSDKAppEvents logEvent:FBSDKAppEventNameViewedContent
    FBSDKAppEventParameterNameCurrency    : @"USD",
    FBSDKAppEventParameterNameContentType : @"product",
    FBSDKAppEventParameterNameContentID   : @"123456789"
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");


NOTE For iOS: You must always provide FBSDKAppEventParameterNameContentType and FBSDKAppEventParameterNameContentID for all events otherwise we cannot deliver product ads. Possible values for FBSDKAppEventParameterNameContentType is product or product_group.

NOTE For Android: You must always provide AppEventsConstants.EVENT_PARAM_CONTENT_TYPE and AppEventsConstants.EVENT_PARAM_CONTENT_ID for all events otherwise we cannot deliver product ads. Possible values for AppEventsConstants.EVENT_PARAM_CONTENT_TYPE is product or product_group.

You can also provide a JSON array of values for product ID when an event occurs for multiple products For example, you can send multiple products with the Purchase event.

[FBSDKAppEvents logPurchase:54.23 currency:@"USD" parameters:@{
  FBSDKAppEventParameterNameContentID   : @"['1234','5678']",
  FBSDKAppEventParameterNameContentType : @"product"
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']");


Multiple Content IDs

If you have multiple content IDs, you provide an escaped JSON array, for example:


Optional Parameters

For every app event, you can send additional parameters, you should send them when someone makes a purchase:

Field Name Description Type Required


Value of the product or purchase amount




Currency of the product or purchase amount



Using a Mobile Measurement Partner (MMP)

If you use an approved Mobile Measurement Partner (MMP) to report events to Facebook, you can adjust your implementation to also send the required events. While this process varies by MMP, typically it looks like this:

  1. Adjust your integration to report the three required events to the MMP, along with the required parameters
  2. With your MMP, map your event names to the Facebook event names
  3. Test App Events

Required Events for MMP

The following events are required:

Event name Description


When a person has viewed a product.


When a item has been added to the cart.


When a item/items have been purchased.

You must also send two additional parameters for Dynamic Ads to function:

  • An id of the item viewed, added to cart or purchased and -Whether the id is a product or product group id.

The additional parameters available are:

Field Name Description Type Required


either 'product' or 'product_group'




The retailer's product or product group ids. String containing a JSON-encoded array of ids




Value of the product purchased




Currency of the product or purchase amount



You should also send _valueToSum and fb_currency parameters when someone purchases items.

Testing App Events

The easiest way to test your integration works is App Ads Helper. See the events and paramters reported to Facebook in realtime.

After you select an app, you see two tools at the bottom of the page. Select "Test App Events":

You have two options: either see events being reported by you, or by a specific Advertising ID. In most cases, selecting "Me" is sufficient. Make sure you have Facebook installed on your device and that you are logged in.

As you perform actions in your app, events appear in the tool with their parameters.

In the tool, you see these three event names if your integration is successful:

App Ads Helper Event Names




Learn more about iOS and Android app events.

To verify your app events function, you can check recent events in Facebook Analytics for Apps.

Step 3: Set Up Deep Linking

By providing deep links in your product feed, anyone who interact with your ad on Facebook can go directly to a specific location of your app. See App Ads, Deep Linking. For instance, when someone clicks an ad in Facebook on mobile, they see the product in your mobile app.

Deep Linking GuideVerify Deep Linking

Fallback to Web versus Appstore

If you use deeplinks, you can specify fallback behavior if someone does not have your app installed. When you provide deep links in your product feed, people without your app see the web URL for the product in the ad.

Since your likely goal is to increase catalog sales, you probably want people to see product pages, rather than your app to install. Therefore we default to web URLs, though you can specify different behavior for more control. Set the fallback behavior with applink_treatment when you create your Dynamic Ad. You have these options:

Field Name Description


Always send someone to the given web URL. This overrides any deeplinks in your feed.


If the app is installed and we have your corresponding deep links, send someone to your app. If one of these conditions is unfulfilled, send them to the website URL.


If the app is installed and we have corresponding deep link information, send someone to the app. If the app is not installed, send them to the app store for the app.

Step 4: Set Up Product Feed

Now you need to provide actual deep links for your Dynamic Ads, see Product Catalog, Deep Linking.

Step 5: Track Specs

To measure conversion events from both your website and mobile apps, make sure any Dynamic Ads have the correct Tracking Specs set for these events:

Event Tracking Spec


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





Facebook can then track any events occurring from a Dynamic Ad, regardless of if someone views your website, or app. To set these tracking specs:

use FacebookAds\Object\Ad;
use FacebookAds\Object\Fields\AdFields;

$ad = new Ad(<AD_ID>);

$ad->{'tracking_spec'} = array(
    'action.type' => array('app_custom_event'),
    'application' => array($app_id),
    'action.type' => array('offsite_conversion'),
    'offsite_pixel' => array(<PIXEL_ID>),
    'action.type' => array('mobile_app_install'),
    'application' => array($app_id),

curl \
  -F 'tracking_spec=[ 
  ]' \
  -F 'access_token=<ACCESS_TOKEN>' \