Back to News for Developers

Call Now

May 20, 2015ByLuca Bruno

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();
from facebookads.objects import AdCreative
from facebookads.specs import LinkData, ObjectStorySpec

link_data = LinkData()
link_data[link_data.Field.link] = 'https://www.facebook.com/<PAGE_ID>'
link_data[link_data.Field.message] = 'Try our solutions'
link_data[link_data.Field.description] = 'Call us to find out more'
link_data[link_data.Field.picture] = '<IMAGE_URL>'
link_data[link_data.Field.call_to_action] = {
'type': 'CALL_NOW',
'value': {
'link': 'tel:<TELEPHONE_NUMBER>',
},
}

story_spec = ObjectStorySpec()
story_spec[ObjectStorySpec.Field.page_id] = <PAGE_ID>
story_spec[ObjectStorySpec.Field.link_data] = link_data

creative = AdCreative(parent_id='act<AD_ACCOUNT_ID>')
creative[AdCreative.Field.object_story_spec] = story_spec
creative.remote_create()
curl \
-F "object_story_spec={ \
\"page_id\": \"<PAGE_ID>\", \
\"link_data\": { \
\"link\": \"https://www.facebook.com/<PAGE_ID>\", \
\"message\": \"Try our solutions\", \
\"description\": \"Call us to find out more\", \
\"picture\": \"<PICTURE_URL>\", \
\"call_to_action\": { \
\"type\": \"CALL_NOW\", \
\"value\": { \
\"link\": \"tel:<TELEPHONE_NUMBER>\" \
} \
} \
} \
}" \
-F "access_token=<ACCESS_TOKEN>" \
https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/adcreatives

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'
));
from facebookads.objects import AdGroup, Insights

adgroup = AdGroup(<ADGROUP_ID>)

params = {
'date_preset': 'yesterday'
}

insights = adgroup.get_insights([
Insights.Field.adgroup_id,
Insights.Field.call_to_action_clicks,
], params)
curl -G \
-d "date_preset=yesterday" \
-d "fields=adgroup_id,call_to_action_clicks" \
-d "access_token=<ACCESS_TOKEN>" \
https://graph.facebook.com/<API_VERSION>/<ADGROUP_ID>/insights

Find more in-depth examples in our Local Awareness Guide.


Tags: