App Events for Collaborative Ads - Android

Collaborative Ads allows producers, such as consumer-packaged goods advertisers, to run ad campaigns to drive people to merchant platforms. Such platforms include online retailer websites or apps and those that can measure, retarget, and optimize towards people who have interacted with the producers' products on the merchant platforms. Access to the Collaborative Ads features is provided on a limited basis only. Please contact your Facebook Representative.

To use Collaborative Ads features, the merchants need to implement the following required standard events with their respective parameters. If you're unfamiliar with app events and parameters, or you need to set up Facebook SDK for Android, see Getting Started with App Events for Android first.


Required Standard Events

The merchant platform needs to provide the following standard events.

Event Name: AppEventsConstants Value Event Description Required Parameters Optional Parameters

View Content: EVENT_NAME_VIEWED_CONTENT

valueToSum: Price of item viewed (if applicable)

When a product page is viewed.

A person lands on a product details page.

CONTENT or CONTENT_ID, and CONTENT_TYPE

CURRENCY

Add to Cart: EVENT_NAME_ADDED_TO_CART

valueToSum: Price of item added (required)

When a product is added to the shopping cart.

A person clicks on an add to cart button.

CONTENT, CONTENT_TYPE, and CURRENCY

Purchase:

`EVENT_NAME_PURCHASED`

Use the logPurchase method instead.

valueToSum: Purchase price (required)

When a purchase is made or checkout flow is completed.

A person has finished the purchase or checkout flow and lands on thank you or confirmation page

CONTENT, CONTENT_TYPE, and CURRENCY


Parameters

Parameter: AppEventConstants::EVENT_PARAM_* Description Value Type

Content: EVENT_PARAM_CONTENT

A string of an array of JSON objects that contains the International Article Number (EAN) when applicable, or other product or content identifier(s) associated with the event (Product Group ID is not supported) and quantities of the products.


Required: id and quantity.


Example: "[{\"id\": \"ABC123\", \"quantity\": 2}, {\"id\": \"XYZ789\", \"quantity\": 2}]"


Note: This parameter is required for Add To Cart and Purchase event and is optional for View Content event if CONTENT_ID is provided.

string

Content ID: EVENT_PARAM_CONTENT_ID

Product IDs associated with the event, such as SKUs (Product Group ID is not supported).


Example: ['ABC123', 'XYZ789']

array of strings

Content Type: EVENT_PARAM_CONTENT_TYPE

Must be "product".


Note: "product_group" and other values are not supported

string

Currency: EVENT_PARAM_CURRENCY

Currency for the value specified in ISO 4217 currency code.


Example: "USD", "GBP", "JPY"

string

Value: valueToSum

Value of a user performing this event to the business.

  • For View Content, value of an item.
  • For Add to Cart, the value of new items added to cart at once. It's not the current total basket value.
  • For Purchase, the total basket value, including other fees, such as shipping fee and tax.

Example: 21.5

integer or float


Examples

ViewContent Event

AppEventsLogger logger = AppEventsLogger.newLogger(this);
Bundle params = new Bundle();
params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, "product");
params.putString(AppEventsConstants.EVENT_PARAM_CONTENT, "[{\"id\": \"1234\", \"quantity\": 1}]");
params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "USD");
logger.logEvent(AppEventsConstants.EVENT_NAME_VIEWED_CONTENT, 90.0, params);

Or, with minimal parameters:

AppEventsLogger logger = AppEventsLogger.newLogger(this);
Bundle params = new Bundle();
params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, "product");
params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, "1234");
params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "USD");
logger.logEvent(AppEventsConstants.EVENT_NAME_VIEWED_CONTENT, 90.0, params);

Note: The minimal parameter setup is valid for ViewContent only and not valid for AddToCart and Purchase.

AddToCart Event

AppEventsLogger logger = AppEventsLogger.newLogger(this);
Bundle params = new Bundle();
params.putString(AppEventsConstants.EVENT_PARAM_CONTENT, "[{\"id\": \"1234\", \"quantity\": 1}, {\"id\": \"5678\", \"quantity\": 1}]");
params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, "product");
params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "USD");
logger.logEvent(AppEventsConstants.EVENT_NAME_ADDED_TO_CART, 90.0, params);

Purchase Event

AppEventsLogger logger = AppEventsLogger.newLogger(this);
Bundle params = new Bundle();
params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, "product");
params.putString(AppEventsConstants.EVENT_PARAM_CONTENT, "[{\"id\": \"1234\", \"quantity\": 2}, {\"id\": \"5678\", \"quantity\": 1}]");
logger.logPurchase(BigDecimal.valueOf(15.98), Currency.getInstance("GBP"), params);

Common Mistakes

  • CONTENT: "[{\"id\": \"SKU-123\"}, {\"id\": \"SKU-456\"}]" - Missing quantity key.
  • CONTENT_ID: "SKU-123,SKU-456,SKU-789" - Missing an array symbol.
  • CONTENT_ID: [] - Missing SKU IDs in an array.
  • CONTENT_TYPE: "soap" - The value is not "product".
  • CURRENCY: "$" - Cannot use a currency symbol format.
  • valueToSum: "5000,00" - Wrong format (should not be a string with comma).