1

I have a set of ad creatives that I retreive through the Facebook Business Python SDK. I need these specifically to retreive the outbound URL when someone clicks on the ad: AdCreative['object_story_spec']['video_data']['call_to_action']['value']['link'].

I use the following call:

adcreatives = set.get_ad_creatives(fields=[
                                    AdCreative.Field.id,
                                    AdCreative.Field.name,
                                    AdCreative.Field.object_story_spec,
                                    AdCreative.Field.effective_object_story_id ,
                                ])

Where set is an ad set.

For some cases, the result looks like this (with actual data removed), which is expected:

<AdCreative> {
    "body": "[<BODY>]",
    "effective_object_story_id": "[<EFFECTIVE_OBJECT_STORY_ID>]",
    "id": "[<ID>]",
    "name": "[<NAME>]",
    "object_story_spec": {
        "instagram_actor_id": "[<INSTAGRAM_ACTOR_ID>]",
        "page_id": "[<PAGE_ID>]",
        "video_data": {
            "call_to_action": {
                "type": "[<TYPE>]",
                "value": {
                    "link": "[<LINK>]",   <== This is what I need
                    "link_format": "[<LINK_FORMAT>]"
                }
            },
            "image_hash": "[<IMAGE_HASH>]",
            "image_url": "[<IMAGE_URL>]",
            "message": "[<MESSAGE>]",
            "video_id": "[<VIDEO_ID>]"
        }
    }
}

While sometimes results look like this:

<AdCreative> {
    "effective_object_story_id": "[<EFFECTIVE_OBJECT_STORY_ID>]",
    "id": "[<ID>]",
    "name": "[<NAME>]",
    "object_story_spec": {
        "instagram_actor_id": "[<INSTAGRAM_ACTOR_ID>]",
        "page_id": "[<PAGE_ID>]"
    }
}

According to this earlier question: Can't get AdCreative ObjectStorySpec this is due to the fact that the object_story_spec is not populated if it is linked to a creative, instead of created along with the creative.

However, the video_data (and as such, the link), should be saved somewhere. Is there a way to retreive this? Maybe through effective_object_story_id? The documentation page for object_story_spec (https://developers.facebook.com/docs/marketing-api/reference/ad-creative-object-story-spec/v12.0) does not have the information I am looking for.

OkkeM
  • 38
  • 5

0 Answers0