skip to Main Content

I’m trying to get data using Facebook Marketing API.

$api    = FacebookAds::init('TOKEN');
$start  = Carbon::create(2018,11,16);
$end    = Carbon::create(2018,11,16);
$period = Period::create($start,$end);
$in = $api->insights($period,'act_ID', 'ad',[
   'fields' => ['impressions', 'objective', 'actions'....]
]);

I’m getting each ad actions like this:

    "actions" => array:10 [▼
      0 => array:2 [▼
        "action_type" => "comment"
        "value" => "1"
       ]
       1 => array:2 [▼
         "action_type" => "offsite_conversion.fb_pixel_purchase"
         "value" => "1"
       ]
       2 => array:2 [▼
         "action_type" => "photo_view"
         "value" => "114"
       ]....
    ]

My question is how to get each ad destination URL?
Thanks

2

Answers


  1. You actually have to use AdCreative information to get the destination URL: https://developers.facebook.com/docs/marketing-api/reference/ad-creative/

    I use the object_story_spec and match the AdCreative with the Ad by id ( they share the same ID ).

    Login or Signup to reply.
  2. https://graph.facebook.com/v14.0/'adcreativeid'/?fields=object_story_spec

    You can use this code. Destination URL will mentioned in link data -> link

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search