Prepare your tags
Depending on the type of platform you're adding to Facebook Attribution, you may need to modify the Facebook-provided impression and click tags before applying them to your off-Facebook media.
For example, you may need to select the image or Javascript version of a tag or hard code attributes of your marketing campaigns into a tag. You may also need to combine Facebook's click tag with other third-party tags you're using to create a single URL, or encode characters in the URL. Learn how to prepare your tags and see common tag examples.
Facebook Attribution provides two types of impression tags, image tags and JavaScript impression tags. These tags have different capabilities and URL components.
Image version of an impression tag:
- Contains "img" (https://ad.atdmt.com/i/img;...).
- Returns a cookie ID (if one isn't already set), along with a single pixel (1x1).
- Enables attribution reporting.
JavaScript version of an impression tag:
- Contains "js" (https://ad.atdmt.com/i/t.js;...).
- Returns additional JavaScript code to your browser, which is used to measure viewability and fraud.
- Must be used if you wish to measure viewability; also enables attribution reporting.
Learn more about preparing tags.
Hard coding refers to embedding value parameters directly in click and impression tags, instead of obtaining the data from external sources. You may want to hard code values in tags when value parameters won't change across campaigns and aren't considered dynamic (ex: site name). In some cases, Facebook Attribution will hard code site name values directly in the tags. This configuration allows for consistency across your campaigns, no matter who is implementing or generating the tags.
You may also want to hard code values in tags when third-party sources, such as publishers and ad servers, don't support macros for certain objects like campaigns, placements, and ad groups. In these cases, you can hard code specific value parameters in the tags to avoid having to create individual 1x1 tags.
The following example tags display hard coded site names ("s.a"):
https://ad.atdmt.com/i/img;adv=1234566666;ec=4444444444;c.a={campaignid};s.a=google;
https://ad.atdmt.com/i/img;adv=1234566666;ec=4444444444;c.a={campaignid};s.a=yahoo;
https://ad.atdmt.com/i/img;adv=1234566666;ec=4444444444;c.a={campaignid};s.a=criteo;
Chaining, or concatenating, URLs is necessary when you have more than one click tag URL but only have the option to enter a single URL string on a platform.
To chain a third-party click tag to a Facebook-provided click tag, append it to the "h=" parameter of the Facebook-provided click tag. Make sure that the third-party click tag is encoded so that each part of the URL is correctly interpreted.
Example of encoded chained click tag:
https://ad.atdmt.com/c/img;adv=000;ec=111;adv.a=222;c.a=333;s.a=444;p.a=555;a.a=666;cache=777;qpb=1;?h=http%3A%2F%2Fwww.3rdparty.com%2Fclick%3Fa%3D123%26b%3D456
How it appears decoded:
https://ad.atdmt.com/c/img;adv=000;ec=111;adv.a=222;c.a=333;s.a=444;p.a=555;a.a=666;cache=777;qpb=1;?h=http://www.3rdparty.com/click?a=123&b=456
Note: If the third-party click tag contains macros, you should not encode the macros.
Example of encoded chained click tags with unencoded macros:
https://ad.atdmt.com/c/img;adv=000;ec=111;adv.a=222;c.a=333;s.a=444;p.a=555;a.a=666;cache=777;qpb=1;?h=http%3A%2F%2Fwww.3rdparty.com%2Fclick%3Fa%3D{macro1}%26b%3D{macro2}
How it appears decoded:
https://ad.atdmt.com/c/img;adv=000;ec=111;adv.a=222;c.a=333;s.a=444;p.a=555;a.a=666;cache=777;qpb=1;?h=http://www.3rdparty.com/click?a={macro1}&b={macro2}
Learn more about preparing tags.
URLs need to be formatted with ASCII characters in order for browsers to correctly interpret them.
There are sets of characters that serve a specific purpose within a URL. For example, "/" is used to separate domains and directories and "?" is used to separate query strings.
":" | "/" | "#" | "?" | "&" | "@" | "%" | "+" | "~" | ";" | "=" | "$" | ","
If any of these characters are used within a URL for any purpose outside of what they're supposed to be used for, they'll need to be encoded. For example, this may happen when these characters form part of a URL within a query parameter ("?"):
- https://ad.atdmt.com/example.html?query1=abc:123
In this example, the colon ":" is being used within a query parameter and therefore should be encoded in order for this URL to be correctly interpreted by the browser.
As a result, the encoded version of the this URL is:
- https://ad.atdmt.com/example.html?query1=abc%3A123
Encoding involves escaping these characters followed by their hexadecimal (two-character) equivalent value, as defined within the US ASCII character set. Escaping is denoted by the percentage sign character "%".
The hex value for ":" is 3A so the complete encoded version of this character becomes %3A.
Learn more about preparing tags.
Bear in mind the following limitations when you're setting up click and impression tags:
- A placement ID can only occur within one site and one campaign for search platforms.
- An ad set ID can only occur within one campaign.
- You can have up to 100,000 campaigns per platform at this time.
- A tag can only contain alphanumeric and ASCII characters (%, $, {}, [], (), <>, _, ., :, !, #, -, ~, A-Z, a-z, 0-9).
- URL parameters must be shorter than 1,024 characters.
Learn more about preparing tags.
Learn about adding platforms to Facebook Attribution to apply impression and click tags.
* Nguồn: Facebook