facebook-graph-apifacebook-marketing-api

Creating an ad creative with multiple asset placements, titles and primary texts with the Meta Marketing API


I want to create an ad creative with the Meta/Facebook Marketing API. The goal is to create an ad creative which I can turn into an ad which has multiple images and primary texts and titles.

As shown in the picture, I want to have the same image in "Feeds, In-Stream Ads for Videos and Reels, Search Results" and "Right Hand, Search Results". I want a different image in "Stories and Reels, Apps and Websites".

Additionally, I want to specify multiple primary texts and multiple titles.

I tried to create the creative using this:

{
    "object_story_spec": {
      "page_id": "PAGE_ID"
    },
    "asset_feed_spec": {
      "images": [
        {
          "hash": "HASH1",
          "adlabels": [{"name": "label_feed"}]
        },
        {
          "hash": "HASH2",
          "adlabels": [{"name": "label_story"}]
        }
      ],
      "bodies": [
        {
          "text": "Begin Your Adventure"
        }
      ],
      "titles": [
        {
          "text": "Level Up"
        },
        {
          "text": "Level Up 2"
        }
      ],
      "call_to_action_types": [
        "SHOP_NOW"
      ],
      "link_urls": [
        {
          "website_url": "https://www.example.com/"
        }
      ],
      "ad_formats": [
        "SINGLE_IMAGE"
      ],
      "asset_customization_rules": [
        {
          "customization_spec": {
            "publisher_platforms": [
              "facebook"
            ],
            "facebook_positions": [
              "feed"
            ]
          },
          "image_label": {
            "name": "label_feed"
          }
        },
        {
          "customization_spec": {
            "publisher_platforms": [
              "instagram"
            ],
            "instagram_positions": [
              "story"
            ]
          },
          "image_label": {
            "name": "label_story"
          }
        }
      ]
   
  },
  "status": "PAUSED",
  "degrees_of_freedom_spec": {
        "creative_features_spec": {
            "standard_enhancements": {
                "enroll_status": "OPT_OUT"
            }
        }
    }
}

However, it gives me an error:

Multiple title elements cannot be applied to rule #1 (Priority, if specified, or index of the rule) in the Ad Asset Feed.

Additionally, it seems like I have to specify adlabels in the asset story spec. How can I place the images in the categories without the adlabels?


Solution

  • If you want to pass two or more titles/bodies for different placements you should specify adlabels for each item and use them in asset_customization_rules section (the same approach as for images).

    So request body will look like this:

    {
        "object_story_spec": {
          "page_id": "PAGE_ID"
        },
        "asset_feed_spec": {
          "images": [
            {
              "hash": "HASH1",
              "adlabels": [{"name": "label_feed"}]
            },
            {
              "hash": "HASH2",
              "adlabels": [{"name": "label_story"}]
            }
          ],
          "bodies": [
            {
              "text": "Begin Your Adventure",
              "adlabels": [{"name": "body_story"}, {"name": "body_feed"}]
            },
            {
              "text": "Begin Your Adventure 2",
              "adlabels": [{"name": "body_story"}, {"name": "body_feed"}]
            }
          ],
          "titles": [
            {
              "text": "Level Up",
              "adlabels": [{"name": "title_story"}, {"name": "title_feed"}]
            },
            {
              "text": "Level Up 2",
              "adlabels": [{"name": "title_story"}, {"name": "title_feed"}]
            }
          ],
          "call_to_action_types": [
            "SHOP_NOW"
          ],
          "link_urls": [
            {
              "website_url": "https://www.example.com/"
            }
          ],
          "ad_formats": [
            "SINGLE_IMAGE"
          ],
          "asset_customization_rules": [
            {
              "customization_spec": {
                "publisher_platforms": [
                  "facebook"
                ],
                "facebook_positions": [
                  "feed"
                ]
              },
              "image_label": {
                "name": "label_feed"
              },
              "title_label": {
                "name": "title_feed"
              },
              "body_label": {
                "name": "body_feed"
              }
            },
            {
              "customization_spec": {
                "publisher_platforms": [
                  "instagram"
                ],
                "instagram_positions": [
                  "story"
                ]
              },
              "image_label": {
                "name": "label_story"
              },
              "title_label": {
                "name": "title_story"
              },
              "body_label": {
                "name": "body_story"
              }
            }
          ]
       
      },
      "status": "PAUSED",
      "degrees_of_freedom_spec": {
            "creative_features_spec": {
                "standard_enhancements": {
                    "enroll_status": "OPT_OUT"
                }
            }
        }
    }