Click Tracking Tags are URLs that fire when someone clicks on an ad. This tag gets fired on offsite link clicks on any ad unit that supports offsite links such as domain ads and page post link ads. These tags only fire when the ad is served on desktop such as feed and right hand side, but not on mobile. A click tag can redirect once. Click tags are not fired:
Only one click tracking tag per ad is allowed. Marketing API click tags will not fire on mobile; however click tags in Atlas are fired on mobile.
Keywords Stats are specific to each interest, or keyword, targeted by an ad. Provide keywords in ad set targeting spec. Keywords are known as Interests
in Ads Manager. See also Ad Keyword Stats, Reference.
To create a click tracking tag for an ad, make an HTTP POST
: https://graph.facebook.com/{API_VERSION}/{AD_ID}/trackingtag
.
use FacebookAds\Object\ClickTrackingTag;
use FacebookAds\Object\Fields\ClickTrackingTagFields;
$clicktrackingtag = new ClickTrackingTag(null, '<AD_ID>');
$clicktrackingtag->setData(array(
ClickTrackingTagFields::URL => 'https://www.mytagprovider.com',
ClickTrackingTagFields::ADD_TEMPLATE_PARAM => 1,
));
$clicktrackingtag->create();
from facebookads.adobjects.clicktrackingtag import ClickTrackingTag
clicktrackingtag = ClickTrackingTag(parent_id=<AD_GROUP_ID>)
clicktrackingtag[ClickTrackingTag.Field.url] = 'https://www.mytagprovider.com'
clicktrackingtag[ClickTrackingTag.Field.add_template_param] = 1
clicktrackingtag.remote_create()
curl \
-F 'url=https://www.mytagprovider.com' \
-F 'add_template_param=1' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/<AD_ID>/trackingtag
You have this option:
name | type | description | required |
---|---|---|---|
url | string | Full, valid URL of click tracking tag. 1024 char limit. Do not URL encode. No restrictions on tag provider | yes |
add_template_param | integer | If 1, Facebook postpends | no |
The response is:
name | type | description |
---|---|---|
id | integer | ID of click tracking tag |
To retrieve information about a tag, make an HTTP GET
: https://graph.facebook.com/{API_VERSION}/{CLICK_TAG_ID}
. The response contains these fields:
name | type | description |
---|---|---|
id | integer | ID of object |
url | string | Full URL of tag, with |
adgroup_id | integer | ID of ad tags belongs to |
Make updates to the url
field with HTTP POST
to https://graph.facebook.com/{API_VERSION}/{AD_ID}/trackingtag
. Use these options to overwrite fields. You have the same options, restrictions and return value for url
as you do when you create a tag.
To delete, make an HTTP DELETE
to https://graph.facebook.com/{API_VERSION}/{AD_ID}/trackingtag
The response is {"success":true}
.
Query the keywordstats
connection of the Ad object:
<API_VERSION>/<AD_ID>/keywordstats
To query from a particular day in the last week:
<API_VERSION>/<AD_ID>/keywordstats?date=YYYY-MM-DD
A sample response looks like this:
{
"data": {
"Good Housekeeping": {
"id": "<id>",
"name": "Good Housekeeping",
"impressions": "65205",
"unique_impressions": "52824",
"clicks": "3209",
"unique_clicks": "3175",
"total_actions": "3383",
"total_unique_actions": "2973",
"actions": [
{
"action_type": "photo_view",
"value": "42"
},
{
"action_type": "video_view",
"value": "40"
},
{
"action_type": "post",
"value": "31"
},
....
}
],
"unique_actions": [
{
"action_type": "photo_view",
"value": "38"
},
{
"action_type": "video_view",
"value": "17"
},
....
"action_type": "post_like",
"value": "56"
},
{
"action_type": "like",
"value": "2929"
},
....
}
]
},
"Better Homes and Gardens (TV series)": {...}
}
}