Marketing API Version

Click Tracking Tags

You can specify a URL which is fired when someone clicks on an ad. Specifically, this tag gets fired upon 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 on clicks of the ad's actor such as the page name in a page post ad, or the user's name in a permalink, photo, like, share, or comment buttons. These tags are also not fired on ads that do not have offsite actions, such as page like ads.

Unlike the Marketing API click tags, click tags in Atlas will be fired on mobile.

Create a Tag

To create an click tracking tag for an ad, make an HTTP POST call to

 https://graph.facebook.com/<API_VERSION>/<AD_ID>/trackingtag

with the following fields:

nametypedescriptionrequired

url

string

Full, valid URL of the click tracking tag (1024 char limit). Do not URL encode. No restrictions on tag provider

yes

add_template_param

integer

If set to 1, Facebook will append fb_adgroup_id=<AD_ID> onto the end of the url specified. Default is 0

no

The response is:

nametypedescription

id

integer

ID of click tracking tag

Only one click tracking tag per ad is allowed.

Read

To retrieve information about a click tracking tag, make an HTTP GET call to

 https://graph.facebook.com/<API_VERSION>/<CLICK_TAG_ID>

The response will contain the following fields:

nametypedescription

id

integer

ID of object

url

string

Full URL of the click tracking tag, with fb_adgroup_id appended, if specified

adgroup_id

integer

ID of the ad the tag is associated with

Update

You can make updates to the certain fields by specifying an HTTP POST call to

 https://graph.facebook.com/<API_VERSION>/<AD_ID>/trackingtag

with the following fields. Your previous tag information will be overwritten:

nametypedescriptionrequired

url

string

Full, valid URL of the click tracking tag (1024 char limit). Do not URL encode

yes

add_template_param

integer

If set to 1, Facebook will append fb_adgroup_id=<AD_ID> onto the end of the url specified. Default is 0

no

The response will be:

nametypedescription

id

integer

ID of click tracking tag

Delete

To delete a click tracking tag make an HTTP DELETE call to

 https://graph.facebook.com/<API_VERSION>/<AD_ID>/trackingtag

The response will be {"success":true}.

Examples

Creating a tag for an ad

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.8/<AD_ID>/trackingtag