| Event | iOS Event | Android Event |
|---|---|---|
Search | FBSDKAppEventNameSearched | EVENT_NAME_SEARCHED |
View Content | FBSDKAppEventNameViewedContent | EVENT_NAME_VIEWED_CONTENT |
Add To Cart | FBSDKAppEventNameAddedToCart | EVENT_NAME_ADDED_TO_CART |
Purchase | // Send through logPurchase [[FBSDKAppEvents shared] logPurchase:(double) currency:(NSString *) parameters:(NSDictionary *)]; | EVENT_NAME_PURCHASED |
content_id (or a JSON array of content_ids).product_catalog_id parameter. Therefore you must make an association between your catalog and app with the external_event_sources endpoint described below.[[FBSDKAppEvents shared] logEvent:FBSDKAppEventNameAddedToCart
valueToSum:54.23
parameters:@{
FBSDKAppEventParameterNameCurrency : @"USD",
FBSDKAppEventParameterNameContentType : @"product",
FBSDKAppEventParameterNameContentID : @"123456789"
}
];
[[FBSDKAppEvents shared] logPurchase:21.97
currency:@"USD"
parameters:@{
FBSDKAppEventParameterNameContent : @"[{\"id\":\"1234\",\"quantity\":2},{\"id\":\"5678\",\"quantity\":1}]",
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\",\"quantity\":2},{\"id\":\"5678\",\"quantity\":1}]");
logger.logEvent(
AppEventsConstants.EVENT_NAME_PURCHASED,
21.97,
parameters
);
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,
21.97,
parameters
);
CONTENT_ID or CONTENT can be used with Advantage+ catalog ads to report product IDs. The CONTENT param will allow you to provide additional information about the products.| Name | Description |
|---|---|
fb_mobile_search | Someone searches for products |
fb_mobile_content_view | When an Accounts Center account views a product |
fb_mobile_add_to_cart | Someone ads an item to the cart |
fb_mobile_purchase | An Accounts Center account purchases one or more items |
| Name | Description |
|---|---|
fb_content_id
string
| Either fb_content_id or fb_content is required.The retailer’s product or product group ID(s). This should be a string containing a JSON-encoded array of IDs. Use product IDs if possible for more accurate targeting. |
fb_content
string
| Either fb_content_id or fb_content is required.A list of JSON objects that contains the International Article Number (EAN) when applicable, or other product or content identifier(s) as well as quantities and prices of the products. The id and quantity fields are the required.Example: "[{\"id\": \"1234\", \"quantity\": 2}, {\"id\": \"5678\", \"quantity\": 1}]" |
fb_content_type
string
| Optional. Either product or product_group, which needs to sync with the type of IDs used as fb_content_id.If no fb_content_type is provided, Meta will match the event to every item that has the same ID, independent of its type.
See “Choosing the right content_type” to learn more. |
_valueToSum
string
| Optional. The total value of the products. |
fb_currency
string
| Optional. The currency of the product or purchase amount. |
_valueToSum and fb_currency parameters when a purchase is made.SearchViewCategoryViewContentAddToCartPurchase| Name | Description |
|---|---|
content_ids
string or string[]
| Either content_ids or contents is required.The retailer’s product or product group id(s). Use product IDs if possible for more accurate targeting. |
contents
object[]
| Either content_ids or contents is required.A list of JSON objects that contains the retailer’s product or product group ID(s) as well as additional information about the products. The id and quantity fields are requiredExample:. [{"id": "1234", "quantity": 2}, {"id": "5678", "quantity": 1}] |
content_type
string
| Optional. Either product or product_group, which needs to sync with the type of IDs used as content_ids.If no content_type is provided, Meta will match the event to every item that has the same ID, independent of its type.
See “Choosing the right content_type” to learn more. |
product_catalog_id
string
| Optional. The product catalog to be used. If this is supplied this will be the only catalog Pixel fires will be associated with. If this is not supplied, the catalog(s) associated with your Pixel will be used. See Associate User Signals to Product Catalog to learn more. |
Search standard event is shown below. We recommend providing 5 to 10 items in content_ids from your top search results.<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','https://connect.facebook.net/en_US/fbevents.js');
// Insert Your Facebook Pixel ID below.
fbq('init', '<FB_PIXEL_ID>');
fbq('track', 'PageView');
fbq('track', 'Search', {
search_string: 'leather sandals',
content_ids: ['1234', '2424', '1318', '6832'], // top 5-10 search results
content_type: 'product'
});
</script>
<!-- End Facebook Pixel Code -->
ViewCategory event is shown below. We recommend providing 5 to 10 items in content_ids from your top results. Note that ViewCategory is not a standard event, thus the trackCustom function is used.<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','https://connect.facebook.net/en_US/fbevents.js');
// Insert Your Facebook Pixel ID below.
fbq('init', '<FB_PIXEL_ID>');
fbq('track', 'PageView');
fbq('trackCustom', 'ViewCategory', {
content_name: 'Really Fast Running Shoes',
content_category: 'Apparel & Accessories > Shoes',
content_ids: ['1234', '2424', '1318', '6832'], // top 5-10 results
content_type: 'product'
});
</script>
<!-- End Facebook Pixel Code -->
ViewContent standard event is shown below. For more details on Pixel setup, see Meta Pixel.<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','https://connect.facebook.net/en_US/fbevents.js');
// Insert Your Facebook Pixel ID below.
fbq('init', '<FB_PIXEL_ID>');
fbq('track', 'PageView');
fbq('track', 'ViewContent', {
content_ids: ['1234'],
content_type: 'product',
value: 0.50,
currency: 'USD'
});
</script>
<!-- End Facebook Pixel Code -->
AddToCart standard event depends on how your eCommerce platform handles adding an item to a cart. If it is done dynamically this should be placed in an onclick event handler so it is triggered on the button click. If a separate page is loaded then the Pixel event can be fired like normal.<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','https://connect.facebook.net/en_US/fbevents.js');
// Insert Your Facebook Pixel ID below.
fbq('init', '<FB_PIXEL_ID>');
fbq('track', 'PageView');
// If you have a separate add to cart page that is loaded.
fbq('track', 'AddToCart', {
content_ids: ['1234', '1853', '9386'],
content_type: 'product',
value: 3.50,
currency: 'USD'
});
</script>
<!-- End Facebook Pixel Code -->
<!-- The below method uses jQuery, but that is not required -->
<button id="addToCartButton">Add To Cart</button>
<!-- Add event to the button's click handler -->
<script type="text/javascript">
$( '#addToCartButton' ).click(function() {
fbq('track', 'AddToCart', {
content_ids: ['1234'],
content_type: 'product',
value: 2.99,
currency: 'USD'
});
});
</script>
Purchase standard event with two items with quantity:<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','https://connect.facebook.net/en_US/fbevents.js');
// Insert Your Facebook Pixel ID below.
fbq('init', '<FB_PIXEL_ID>');
fbq('track', 'PageView');
fbq('track', 'Purchase', {
contents: [
{'id': '1234', 'quantity': 2},
{'id': '4642', 'quantity': 1}
],
content_type: 'product',
value: 21.97,
currency: 'USD'
});
</script>
<!-- End Facebook Pixel Code -->
Purchase standard event with two items:<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','https://connect.facebook.net/en_US/fbevents.js');
// Insert Your Facebook Pixel ID below.
fbq('init', '<FB_PIXEL_ID>');
fbq('track', 'PageView');
fbq('track', 'Purchase', {
content_ids: ['1234', '4642'],
content_type: 'product',
value: 21.97,
currency: 'USD'
});
</script>
<!-- End Facebook Pixel Code -->
content_typefb_content_type is the content type for mobile.product for content_type and pass the product IDs (that is, id column in the Product Feed) in content_ids. All AddToCart and Purchase events should use content_type=product because people buy specific products. People don’t buy an amorphous shirt of indeterminate size and color; they buy a specific shirt with a specific size and color.product_group and pass the product group IDs (that is, item_group_id column in the Product Feed) in content_ids. A common usecase is a ViewContent page where the user has not chosen a size yet. Do not use product_group with AddToCart or Purchase.content_type matches the type of ID(s) included in the content_ids or contents parameter.content_type=product) allows Meta to recommend more relevant products because it knows which specific variant (size, color, and so on) the user expressed interest in. We will always show products (not product groups), even if content_type=product_group.content_type is provided, Meta will match the event to every item that has the same ID, independent of its type. Sending content_type is recommended, as it will give you more control over which specific ID you want to match the event.POST API call with a list of external event sources as a UTF-8 encoded query string parameters:curl \
-F 'external_event_sources=["<PIXEL_ID>","<APP_ID>"]' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v25.0/<PRODUCT_CATALOG_ID>/external_event_sources
| Name | Description |
|---|---|
external_event_sources | Required. An array of app and Pixel IDs to associate, as UTF-8 encoded query string parameters |
SearchViewContentAddToCartPurchasePOST API call to the /act_{ad-account-id}/product_audiences endpoint.https://graph.facebook.com/v25.0/act_AD_ACCOUNT_ID/product_audiences
| Name | Description |
|---|---|
name
string
| Required. The name of the audience. |
description
string
| Optional. A description of the audience. |
product_set_id
numeric string
| Required.
The product set to target with this audience. |
inclusions
JSON object
| Required. A set of events to target. At least one inclusion is required. Each inclusion should have exactly one event. |
inclusions.retention_seconds
int
| Required. The number of seconds to keep the Accounts Center account in the audience. |
inclusions.rule
object[]
| |
exclusions
JSON object
| Optional. Events for which an Accounts Center account should be excluded from targeting. For exclusions, an Accounts Center account with these events will be excluded from targeting if the event has happened on any product in the same product group (i.e., products that have the same item_group_id in the product feed).For example, a product audience is set to include ViewContent and exclude Purchase events. An Accounts Center account views product A and B and purchases product B. If product A and product B belong to the same product group then that Accounts Center account will be excluded from the product audience because A and B are just variants. If product A and B are not in the same product group, the Accounts Center account will continue to remain in the audience because he still has a ViewContent event for product A. |
exclusions.retention_seconds
int
| Required, if exclusion is specified. The number seconds to retain the exclusion. |
exclusions.rule
object[]
|
event with the eq operator either as a top-level rule or as part of a top-level and rule.event is used in both inclusions and exclusions, any additional parameter checks must be exactly the same.curl -X POST \
-F 'name="Test Product Audience"' \
-F 'product_set_id="<PRODUCT_SET_ID>"' \
-F 'inclusions=[
{
"retention_seconds": 86400,
"rule": {
"event": {
"eq": "AddToCart"
}
}
},
{
"retention_seconds": 72000,
"rule": {
"event": {
"eq": "ViewContent"
}
}
}
]' \
-F 'exclusions=[
{
"retention_seconds": 172800,
"rule": {
"event": {
"eq": "Purchase"
}
}
}
]' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v25.0/act_<AD_ACCOUNT_ID>/product_audiences
userAgent parameter in your Meta Pixel.curl -X POST \
-F 'name="Test Iphone Product Audience"' \
-F 'product_set_id="<PRODUCT_SET_ID>"' \
-F 'inclusions=[
{
"retention_seconds": 86400,
"rule": {
"and": [
{
"event": {
"eq": "AddToCart"
}
},
{
"userAgent": {
"i_contains": "iPhone"
}
}
]
}
}
]' \
-F 'exclusions=[
{
"retention_seconds": 172800,
"rule": {
"event": {
"eq": "Purchase"
}
}
}
]' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v25.0/act_<AD_ACCOUNT_ID>/product_audiences
data_source parameter.act_{ad-account-id}/product_audiences endpoint is a special POST endpoint to construct these audiences.curl -X GET \
-d 'fields="data_source,subtype"' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v25.0/act_<AD_ACCOUNT_ID>/customaudiences
curl -G \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v25.0/<PRODUCT_AUDIENCE_ID>