how to manage dynamic content id in facebook ads

Dynamic Ads

Dynamic Ads are ads dynamically created by populating an ad template with product information found in a data feed. This allows you to create thousands of ads without having to configure each of them individually. You can also use Dynamic Ads to target visitors based on how they have interacted with your website in the past.

The general steps for creating Dynamic Ads are:

  1. Set up conversion tracking for the specific standard events and their parameter object properties listed below, then
  2. Use the Commerce Manager to set up a dynamic ad set that targets those events

Requirements

  • You must have a Facebook Page for the business that your dynamic ads will apply to.
  • The pixel base code must already be installed.
  • You must have access to the Facebook Ads Manager.

Standard Events

Before you can set up dynamic ads, you must first be tracking the following standard events. You must also include a parameter object with specific object properties with each tracked event.

Required EventRequired Object Properties
AddToCartcontent_type and either content_ids or contents
Purchasecontent_type and either content_ids or contents
ViewContentcontent_type and either content_ids or contents

Refer to the Object Properties section below to learn what values to assign to the required object properties.

Object Properties

content_type

The content_type object property’s value must be set to either product, or product_group, depending on how you will configure your data feed when you set up your product catalog in the Commerce Manager.

If you will be tracking events associated with individual products, set the value to product. If you are tracking events associated with product groups, set it to product_group instead.

For example, here’s how you could track a visitor who has added the product with the ID 201 to a shopping cart. The ID matches the ID for that product in the product catalog.

fbq('track', 'AddToCart',
  // begin required parameter object
  {
    value: .5,
    currency: 'USD',
    content_type: 'product', // required property
    content_ids: '201' // required property, if not using 'contents' property
  }
  // end required parameter object
);

content_ids

If you are using the content_ids property in your parameter object, its value should correspond to the product ID or product IDs associated with the action. IDs must match the IDs found in your product catalog. Values can be either single IDs, or an array of IDs.

For example, here’s how to track a visitor who has added products with the IDs 201 and 301 to a shopping cart. The IDs match the IDs for those products in the product catalog.

fbq('track', 'AddToCart',
  // begin required parameter object
  {
    value: .5,
    currency: 'USD',
    content_type: 'product', // required property
    content_ids: ['201', '301'] // required property, if not using 'contents' property
  }
  // end required parameter object
);

contents

If you are using the contents property in your parameter object, in a sub-object, you must include the id property, with the product ID or product IDs as its value, and include the quantity property with a number of product items being added to cart or purchased. IDs must match the IDs found in your product catalogcontents property value must be an array of objects.

For example, here’s how to track a visitor who has added a product with the ID 301, and two products with the ID 401, to a shopping cart. The IDs match the IDs for those products in the product catalog.

fbq('track', 'AddToCart', {
  value: .5,
  currency: 'USD',
  contents: [
    {
      id: '301',
      quantity: 1
    },
    {
      id: '401',
      quantity: 2
    }],
  content_type: 'product',
});