URL Macros

URL macros are placeholders in a link that an ad platform or ad server replaces with real values when the ad is served or clicked. {{campaign.name}} in a Meta ad becomes the campaign’s name, and {device} in a Google Ads URL becomes the device type. Marketers use them to fill tracking values automatically, so one URL template can tag thousands of ads without manual edits.
How URL Macros Work
You write a macro once, inside the value of a URL parameter. The platform swaps it for a real value on each impression or click, before the visitor’s browser reaches the landing page.
Template: https://example.com/sale?utm_source=facebook&utm_campaign={{campaign.name}}&utm_content={{ad.name}}
Click: https://example.com/sale?utm_source=facebook&utm_campaign=spring-sale&utm_content=video-15s
Analytics tools never see the macro. GA4 receives only the resolved values, as if someone had typed them by hand. That is why the terms “tracking macros” and “dynamic parameters” are often used for the same thing: the parameter stays fixed, and the macro decides its value.
URL Macro Syntax by Platform
Each platform uses its own delimiters. A macro only resolves on the platform that defines it.
- Google Ads: single braces, such as
{campaignid}and{keyword}. Google calls these ValueTrack parameters. - Microsoft Advertising: single braces, such as
{CampaignId}and{Campaign}. Unlike Google, Microsoft offers a campaign-name macro. - Meta Ads: double braces, such as
{{campaign.name}},{{adset.name}}, and{{site_source_name}}. - TikTok Ads: double underscores, such as
__CAMPAIGN_NAME__and__CID__. - Display & Video 360: dollar-brace, such as
${CAMPAIGN_ID}and${CREATIVE_ID}. - Google Ad Manager: double percent signs, such as
%%CACHEBUSTER%%and%%CLICK_URL_UNESC%%.
The custom tracking parameters guide compares the Meta, Google, and TikTok sets side by side.
Types of URL Macros
URL macros fall into four groups based on what they return:
- Name macros return readable labels:
{{ad.name}},__CAMPAIGN_NAME__,{Campaign}. Best forutm_campaignandutm_content. - ID macros return numeric IDs:
{campaignid},{{campaign.id}},${CAMPAIGN_ID}. IDs stay stable when a campaign is renamed, which makes them a good fit for utm_id. - Context macros describe the click: device, network, placement, keyword, or location. Examples are
{device},{{placement}}, and__PLACEMENT__. - Utility macros handle delivery rather than reporting.
{lpurl}inserts the landing page,%%CACHEBUSTER%%adds a random number to defeat caching, and%%CLICK_URL_UNESC%%wraps a click tracker.
Programmatic platforms lean heavily on ID macros. The DSP macros guide explains why Display & Video 360 reports end up full of integers.
URL Macros vs URL Parameters
A URL parameter is the key-value pair in the query string. A URL macro is the placeholder that fills in the value. In utm_campaign={{campaign.name}}, utm_campaign is the parameter and {{campaign.name}} is the macro.
Every macro needs a parameter to live in, but most parameters never use a macro. A link built by hand, such as utm_source=newsletter, has fixed values. The general definition of key-value pairs, including dynamic values set by websites, lives under URL parameters.
Common URL Macro Issues
- Unresolved macros in reports. Seeing
{{ad.name}}or%7Bcampaignid%7Din GA4 means the platform did not recognize the macro. The usual causes are a typo, another platform’s syntax, or a macro the campaign type does not support. - Wrong field. Some macros only work in certain places. Google’s
{lpurl}belongs in the tracking template only. Meta’s macros go in the ad’s URL parameters field. - Renamed campaigns split data. Name macros return the name at click time. Renaming a live campaign creates two rows in reports for one campaign.
- Unreadable IDs. ID macros return numbers like
120210000000000, which need a lookup table to turn into names.
Frequently Asked Questions
What are URL macros?
URL macros are dynamic placeholders that ad platforms replace with real data when an ad is served or clicked. They usually sit inside UTM values, such as utm_campaign={{campaign.name}}. They remove the need to tag each ad’s URL by hand.
What are tracking macros?
Tracking macros are URL macros used for measurement. In paid social and search, they fill UTM values with campaign, ad, and placement data. In ad serving, they also power impression and click trackers, such as %%CACHEBUSTER%% in Google Ad Manager.
Are URL macros the same as dynamic URL parameters?
They are closely related but not identical. A dynamic URL parameter is a parameter whose value changes per click or request. A URL macro is one way to produce that changing value inside an ad platform. Websites can also create dynamic parameters without macros, such as a product ID in a store URL.
Do URL macros work outside ad platforms?
No. A macro only resolves when the platform that defines it builds the final URL. Pasting {{campaign.name}} into an email or social post sends the literal text. Email tools have their own merge tags, such as Mailchimp’s *|FNAME|* format, which work the same way inside that tool.
How do you test a URL macro?
Click a live ad or use the platform’s preview, then read the landing page URL. Google Ads also has a Test button next to the tracking template field. If the URL still shows braces or underscores, the macro did not resolve.
Build the fixed parts of the link with the UTM builder, then run a resolved click URL through the UTM link tester to confirm every macro filled in.