PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, June 29, 2022

[FIXED] How to get the Ad final url with the Facebook insights API

 June 29, 2022     facebook, facebook-graph-api, facebook-sdk-4.0     No comments   

Issue

I'm trying to get an ad final url using the python sdk.

I tried all the fields but I can't manage to find one which returns the ad url. At the moment my fields are:

params = {'access_token':creds.refresh_token,
          'fields':'action_values, actions, ad_name, adset_name, objective, outbound_clicks, outbound_clicks_ctr,  call_to_action_clicks, campaign_name, cost_per_unique_click, cpc, cpm, spend, website_ctr, date_start, date_stop',
          'action_breakdowns':['action_link_click_destination'],
          'date_presets':'last_year',
        # 'time_range':" since:2017-06-01, until:2017-01-03}"
}
ad_insights = requests.get("https://graph.facebook.com/v2.10/{}/insights".format(ad['id']), params=params)

I understand that some ads won't have a final url, like boosting posts, but many ads are only pointing to a site, how can I get the "call to action url" ?


Solution

You have to pull in the adCreative for each ad that AdInsights reports on. The adCreative will contain the outbound link.

See here https://developers.facebook.com/docs/marketing-api/reference/ad-creative

The following fields may be of interest to you

  • object_url
  • url_tags


Answered By - maxTrialfire
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing