We are adding Call Now
call-to-action, allowing businesses to receive calls from people directly from their ad in News Feed.
The example below demostrates how to create an ad creative with Call Now
call-to-action:
Call Now
is available only for ad campaigns with LOCAL_AWARENESS
objective.
Targeting and destination phone number are subjected to some country and age restrictions. To find out more on these restrictions or how to properly format a phone number read the creative section of our Local Awareness Guide.
use FacebookAds\Object\AdCreative;
use FacebookAds\Object\Fields\AdCreativeFields;
use FacebookAds\Object\Fields\ObjectStory\LinkDataFields;
use FacebookAds\Object\Fields\ObjectStorySpecFields;
use FacebookAds\Object\ObjectStory\LinkData;
use FacebookAds\Object\ObjectStorySpec;
use FacebookAds\Object\Values\CallToActionTypes;
$link_data = new LinkData();
$link_data->setData(array(
LinkDataFields::LINK => 'https://www.facebook.com/<PAGE_ID>',
LinkDataFields::MESSAGE => 'Try our solutions',
LinkDataFields::DESCRIPTION => 'Call us to find out more',
LinkDataFields::PICTURE => '<PICTURE_URL>',
LinkDataFields::CALL_TO_ACTION => array(
'type' => CallToActionTypes::CALL_NOW,
'value' => array(
'link' => 'tel:<TELEPHONE_NUMBER>',
),
),
));
$story_spec = new ObjectStorySpec();
$story_spec->{ObjectStorySpecFields::LINK_DATA} = $link_data;
$creative = new AdCreative(null, 'act<AD_ACCOUNT_ID>');
$creative->{AdCreativeFields::OBJECT_STORY_SPEC} = $story_spec;
$creative->create();
To find out how many times the call-to-action button has been clicked, you can access the metric call_to_action_clicks
, which is now available through Insights and Report Stats APIs.
The following example shows how to fetch the number of clicks an ad button received yesterday:
use FacebookAds\Object\AdGroup;
use FacebookAds\Object\Fields\InsightsFields;
$adgroup = new AdGroup(<ADGROUP_ID>);
$insigths = $adgroup->getInsights(array(
InsightsFields::ADGROUP_ID,
InsightsFields::CALL_TO_ACTION_CLICKS,
), array(
'date_preset' => 'yesterday'
));
Find more in-depth examples in our Local Awareness Guide.