Search code examples
javascriptfacebookfacebook-graph-apiads

Getting 'image_overlay_spec' to work Facebook Dynamic Ad Creative


I'm trying to get 'image_overlay_spec' to work when creating Facebook Dynamic ADs. I've already gotten the templating for the actual ad itself to work, but I want to also be able to have info on top of the image.

    object_story_spec: JSON.stringify({
      page_id: process.env.FB_PAGE_ID,
      template_data: {
        description: '{{product.description}}',
        link: 'REDACTED',
        name: '{{product.name | titleize}}',
      },
    }),
    image_overlay_spec: JSON.stringify({
      text_template_tags: ['{{product.price}}'],
      text_type: 'price',
      theme_color: 'background_e50900_text_fffff',
    }),

This is what I have right now. The object_story_spec works as expected, but the image_overlay_spec does not. The API doesn't have any concrete examples on how to make it work.


Solution

  • Found it!

        object_story_spec: JSON.stringify({
          page_id: process.env.FB_PAGE_ID,
          template_data: {
            description: '{{product.description}}',
            link: 'redacted',
            name: '{{product.name | titleize}}',
          },
          image_overlay_spec: JSON.stringify({
            overlay_template: 'pill_with_text',
            text_font: 'droid_serif_regular',
            text_type: 'price',
            position: 'top_right',
            theme_color: 'background_e50900_text_fffff',
            float_with_margin: 'true',
          }),
        }),