Generate leads with your Advantage+ catalog ads. If you have a product catalog ready and run Advantage+ catalog ads, you can collect leads with your ads on Facebook. Facebook selects the most relevant items in your product set, as we do with all Advantage+ catalog ads, and displays a lead generation form when someone clicks on an item.
When you download leads via the API or as a file, we include a retailer_item_id
. This indicates which items someone clicked on and submitted their lead information for.
Create a campaign with the objective
set to LEAD_GENERATION
.
This returns a campaign_id
you can use for your ad set.
As with all Advantage+ catalog ads, you must specify a product_set_id
in promoted_object
for your ad set. This enables you to advertise products from that set. For lead generation, set the optimization_goal
to LEAD_GENERATION
.
use FacebookAds\Object\AdSet;
use FacebookAds\Object\Fields\AdSetFields;
use FacebookAds\Object\Fields\TargetingFields;
use FacebookAds\Object\Values\AdSetBillingEventValues;
use FacebookAds\Object\Values\AdSetOptimizationGoalValues;
$adset = new AdSet(null, 'act_<AD_ACCOUNT_ID>');
$adset->setData(array(
AdSetFields::NAME => 'Product Catalog Sales Adset',
AdSetFields::BID_AMOUNT => 3000,
AdSetFields::BILLING_EVENT => AdSetBillingEventValues::IMPRESSIONS,
AdSetFields::OPTIMIZATION_GOAL =>
AdSetOptimizationGoalValues::LEAD_GENERATION,
AdSetFields::DAILY_BUDGET => 15000,
AdSetFields::CAMPAIGN_ID => <CAMPAIGN_ID>,
AdSetFields::TARGETING => array(
TargetingFields::GEO_LOCATIONS => array(
'countries' => array('US'),
),
TargetingFields::DYNAMIC_AUDIENCE_IDS => array(<DYNAMIC_AUDIENCE_ID>),
),
AdSetFields::PROMOTED_OBJECT => array(
'product_set_id' => <PRODUCT_SET_ID>,
'page_id' => <PAGE_ID>,
),
));
$adset->create(array(
AdSet::STATUS_PARAM_NAME => AdSet::STATUS_PAUSED,
));
curl \
-F 'name=Product Catalog Sales Adset' \
-F 'bid_amount=3000' \
-F 'billing_event=IMPRESSIONS' \
-F 'optimization_goal=LEAD_GENERATION' \
-F 'daily_budget=15000' \
-F 'campaign_id=<CAMPAIGN_ID>' \
-F 'targeting={
"geo_locations": {"countries":["US"]},
"dynamic_audience_ids": ["<DYNAMIC_AUDIENCE_ID>"]
}' \
-F 'promoted_object={"product_set_id":"<PRODUCT_SET_ID>","page_id":"<PAGE_ID>"}' \
-F 'status=PAUSED' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/adsets
DYNAMIC_AUDIENCE_ID
refers to a Product Audience that views your ads. You can omit DYNAMIC_AUDIENCE_ID
s and instead set behavioral or demographic-based targeting to reach an audience by providing the product_audience_specs
or excluded_product_audience_specs
parameter.
See Advantage+ catalog ads for more information.
First, provide ad creative:
use FacebookAds\Object\AdCreative;
use FacebookAds\Object\Fields\AdCreativeFields;
use FacebookAds\Object\Fields\AdCreativeLinkDataFields;
use FacebookAds\Object\Fields\AdCreativeObjectStorySpecFields;
use FacebookAds\Object\AdCreativeObjectStorySpec;
use FacebookAds\Object\AdCreativeLinkData;
use FacebookAds\Object\Values\AdCreativeCallToActionTypeValues;
$object_story_spec = new AdCreativeObjectStorySpec();
$object_story_spec->setData(array(
AdCreativeObjectStorySpecFields::PAGE_ID => <PAGE_ID>,
AdCreativeObjectStorySpecFields::TEMPLATE_DATA =>
(new AdCreativeLinkData())->setData(array(
AdCreativeLinkDataFields::CALL_TO_ACTION => array(
'type' => AdCreativeCallToActionTypeValues::SIGN_UP,
'value' => array(
'lead_gen_form_id' => <FORM_ID>,
),
),
AdCreativeLinkDataFields::MESSAGE => 'Test {{product.name | titleize}}',
AdCreativeLinkDataFields::LINK => '<LINK>',
AdCreativeLinkDataFields::NAME => 'Headline {{product.price}}',
AdCreativeLinkDataFields::DESCRIPTION =>
'Description {{product.description}}',
AdCreativeLinkDataFields::MULTI_SHARE_END_CARD => false,
)),
));
$creative = new AdCreative(null, 'act_<AD_ACCOUNT_ID>');
$creative->setData(array(
AdCreativeFields::NAME => 'Dynamic Ad With Leadgen Template Creative Sample',
AdCreativeFields::OBJECT_STORY_SPEC => $object_story_spec,
AdCreativeFields::PRODUCT_SET_ID => <PRODUCT_SET_ID>,
));
$creative->create();
curl \
-F 'name=Dynamic Ad With Leadgen Template Creative Sample' \
-F 'object_story_spec={
"page_id": "<PAGE_ID>",
"template_data": {
"call_to_action": {"type":"SIGN_UP","value":{"lead_gen_form_id":"<FORM_ID>"}},
"description": "Description {{product.description}}",
"link": "<LINK>",
"message": "Test {{product.name | titleize}}",
"multi_share_end_card": false,
"name": "Headline {{product.price}}"
}
}' \
-F 'product_set_id=<PRODUCT_SET_ID>' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.9/act_<AD_ACCOUNT_ID>/adcreatives
This returns the creative_id
you can use to create or update an ad:
If you have the lead id from a CRM integration you can ask for the details including item_id
.
use FacebookAds\Object\Lead;
$form = new Lead(<LEAD_ID>);
$form->read(array(
LeadFields::FIELD_DATA,
"retailer_item_id",
));
curl -G \
-d 'fields=field_data,retailer_item_id' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/<LEAD_ID>
You can also bulk query all the leads for a form:
use FacebookAds\Object\LeadgenForm;
$form = new LeadgenForm(<FORM_ID>);
$leads = $form->getLeads(array(
LeadFields::FIELD_DATA,
"retailer_item_id",
));
curl -G \
-d 'fields=field_data,retailer_item_id' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/<FORM_ID>/leads
Or for an ad: