Is it possible to obtain the leadgen form (associated with an Ad) from an Ad object?

Digital Marketing Facebook Marketing API 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating
_x000D_ _x000D_ On Business Manager, every Facebook Lead Ad is associated with a leadgen form (whenever I create an Ad, I make a new form for it as well). So it should be possible to retrieve the leadgen form attached to an Ad. I know I can obtain all leadgen forms via a graph link and a page token, but that won't be enough because there's no way to figure out which form is connected to which Ad. That said, here's the response I get by querying for Ads in an Ad Account: [data:protected] => Array ( [account_id] => [ad_review_feedback] => [adlabels] => [adset] => Array ( [id] => 123123123123123 ) [adset_id] => 123123123123123 [bid_amount] => [bid_info] => [bid_type] => ABSOLUTE_OCPM [campaign] => Array ( [id] => 123123123123123 ) [campaign_id] => 123123123123123 [configured_status] => ACTIVE [conversion_specs] => Array ( [0] => Array ( [action.type] => Array ( [0] => leadgen ) [leadgen] => Array ( [0] => 123123123123442 ) ) ) [created_time] => 2017-04-10T16:40:00-0400 [creative] => Array ( [id] => 123123123123123 ) [effective_status] => CAMPAIGN_PAUSED [id] => 12312312312312312 [last_updated_by_app_id] => 123123123123123 [name] => My Ad [recommendations] => Array ( [0] => Array ( [title] => Creative Is Not Eligible For Instagram [message] => Creative is not eligible for Instagram. Your ad will still be eligible to show in other placements. Instagram feed video duration can not be longer than 60 seconds. [code] => 1942020 [importance] => HIGH [confidence] => HIGH [blame_field] => creative ) ) [status] => ACTIVE [tracking_specs] => Array ( [0] => Array ( [action.type] => Array ( [0] => post_engagement ) [page] => Array ( [0] => 123123123123123 ) [post] => Array ( [0] => 123123123123123 ) ) [1] => Array ( [action.type] => Array ( [0] => link_click ) [post] => Array ( [0] => 123123123123123 ) [post.wall] => Array ( [0] => 123123123123123 ) ) ) [updated_time] => 2017-04-10T16:40:53-0400 [date_format] => [display_sequence] => 0 [execution_options] => [redownload] => [filename] => ) That's my Ad Object, from that I can get a lot of things, the Ad Creative, the Ad Account, the campaign, the Adset, etc... It would be great if I can obtain the leadgen form link or ID from somewhere in one of these! The thing that confused me the most was that I thought the leadgen array in the response above was the form ID I needed, but it seems to be the same ID for every Ad Object I queried, and I don't even know what ID that is (not a form ID). Any and all help is appreciated. UPDATE: While digging through Facebook looking for something unrelated, I came across this: $ad = new Ad(); $leads = $ad->getLeads(); So I thought, the following would work: // My Ad Object $ads = $account->getAds(array( AdFields::AD_REVIEW_FEEDBACK, AdFields::ADLABELS, AdFields::ADSET, AdFields::ADSET_ID, AdFields::BID_AMOUNT, AdFields::BID_INFO, AdFields::BID_TYPE, AdFields::CAMPAIGN, AdFields::CAMPAIGN_ID, AdFields::CONFIGURED_STATUS, AdFields::CONVERSION_SPECS, AdFields::CREATED_TIME, AdFields::CREATIVE, AdFields::EFFECTIVE_STATUS, AdFields::LAST_UPDATED_BY_APP_ID, AdFields::NAME, AdFields::RECOMMENDATIONS, AdFields::STATUS, AdFields::TRACKING_SPECS, AdFields::UPDATED_TIME, AdFields::DATE_FORMAT, AdFields::DISPLAY_SEQUENCE, AdFields::EXECUTION_OPTIONS, AdFields::REDOWNLOAD, AdFields::FILENAME )); foreach ($ads as $ad) { print_r($ad->getLeads(array( LeadFields::AD_ID, LeadFields::AD_NAME, LeadFields::ADSET_ID, LeadFields::ADSET_NAME, LeadFields::CAMPAIGN_ID, LeadFields::CAMPAIGN_NAME, LeadFields::CREATED_TIME, LeadFields::CUSTOM_DISCLAIMER_RESPONSES, LeadFields::FIELD_DATA, LeadFields::FORM_ID, LeadFields::ID, LeadFields::IS_ORGANIC, LeadFields::POST ))); However, I get each of the Ad fields up there, but I'm not getting any of the fields from the lead object

Posted on 16 Aug 2022, this text provides information on Facebook Marketing API related to Digital Marketing. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago
_x000D_ Seems like there's no way as of today to obtain a leadgen form from an Ad besides the getLeads() method I've mentioned above; which works fine except it would only return something if there was leads on that form. If there isn't any leads (which there usually isn't if the campaign hasn't been launched, etc)... There's no current way to figure out what form is connected to an Ad via API.

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.