Attribution

UTM parameters for Facebook and TikTok ads: a naming system

UTM parameters for Facebook ads and TikTok ads: the dynamic values each platform fills in, a naming system to copy and the mistakes that break tracking.

·9 min read·By the ROASaurus team

Key takeaways
  • UTM parameters are tags on the ad URL that tell your reports which source, campaign and ad a visit came from.
  • Meta and TikTok fill in campaign, ad set and ad names for you with dynamic parameters, so you set one template and never type names by hand.
  • Use fixed lowercase values for utm_source and utm_medium, and put the campaign id in utm_id, so reports still match after a campaign is renamed.
  • Test every new ad before launch: click through and check that the final URL still has the parameters after every redirect.
  • ROASaurus reads utm_content as the ad name or ad id for creative reports, and utm_id or utm_campaign to match campaign spend to orders.

UTM parameters are tags you add to the landing page URL of an ad, such as utm_source=facebook and utm_campaign=spring-sale, so your reports can tell which source, campaign and ad sent each visit. For Facebook and TikTok ads you do not type the names by hand: both platforms offer dynamic parameters that fill in the campaign, ad set and ad names when someone clicks.

This guide covers the five UTM parameters, the dynamic parameters in Meta and TikTok, a naming system with examples you can copy, the mistakes that break tracking, and how ROASaurus uses UTMs and click ids.

What are the five UTM parameters?

UTM parameters are name and value pairs at the end of a URL, after the question mark. Google Analytics made them common, and most analytics and attribution tools read them. Google says you should always set utm_source, utm_medium and utm_campaign.

ParameterWhat it describesExample for a paid social ad
utm_sourceThe site or platform the visit comes fromfacebook
utm_mediumThe type of marketingpaid
utm_campaignThe campaignus_prospecting_spring-sale
utm_termThe paid keyword in search ads; in paid social, usually the ad setbroad_25-54
utm_contentWhich ad or link, to tell creatives apartThe ad name
utm_idThe campaign id120210000000000001
The five classic parameters plus utm_id. Google Analytics treats values as case sensitive: facebook and Facebook are two different sources.

Google also lists utm_id, a campaign id. It is worth setting, because names change and ids do not. You will see why in the section on mistakes.

Dynamic parameters in Meta Ads Manager

In Meta Ads Manager you add parameters to each ad in its URL parameters field. Meta's dynamic parameters are placeholders in double curly braces. When someone clicks, Meta replaces them with the real value. These are the ones Meta documents:

Dynamic parameterMeta fills in
{{campaign.name}}The campaign name
{{campaign.id}}The campaign id
{{adset.name}}The ad set name
{{adset.id}}The ad set id
{{ad.name}}The ad name
{{ad.id}}The ad id
{{site_source_name}}Where the ad ran: fb, ig, msg (Messenger), an (Audience Network) or th (Threads)
Source: Meta Business Help Center. Meta also offers a placement parameter, and a media type parameter for Advantage+ catalog ads.

A complete template for Meta uses fixed values for source and medium and dynamic parameters for everything else. This is the template ROASaurus recommends in its Meta setup guide:

Meta: paste into the URL parameters field of each ad
utm_source=facebook&utm_medium=paid&utm_campaign={{campaign.name}}&utm_id={{campaign.id}}&utm_term={{adset.name}}&utm_content={{ad.name}}

Three details from Meta's documentation matter here:

  • Names are frozen at publish. Name parameters use the name the campaign, ad set or ad had when the ad was first published. If you rename it later, the URL keeps the old name.
  • Edits can restart learning. Changing URL parameters after you publish may send the ad set back into the learning phase. Set the template before launch.
  • Some parameters may be added for you. Meta may add some parameters on its own: a source, a medium of paid, and the ad, ad set and campaign ids. Check the preview URL so you know what is actually sent.

Dynamic parameters are not supported for collection ads on Instagram placements, according to Meta.

Macros in TikTok Ads Manager

TikTok calls its dynamic values macros. They are written in capital letters between double underscores. In the Ad details section, enter the destination URL, click Edit under the preview and choose Build URL parameters to enter them. TikTok documents these macros:

MacroTikTok fills in
__CAMPAIGN_NAME__The campaign name
__CAMPAIGN_ID__The campaign id
__AID_NAME__The ad group name
__AID__The ad group id
__CID_NAME__The creative name
__CID__The creative id
__PLACEMENT__The placement, such as TikTok or Pangle
Source: TikTok Ads Manager help. Upgraded Smart+ campaigns use __ADID_V2_NAME__ and __ADID_V2__ for the ad name and ad id.
TikTok: the same template with TikTok macros
utm_source=tiktok&utm_medium=paid&utm_campaign=__CAMPAIGN_NAME__&utm_id=__CAMPAIGN_ID__&utm_term=__AID_NAME__&utm_content=__CID_NAME__

Before you launch, open the preview and check that __CID_NAME__ becomes the same name you see for the ad in TikTok Ads Manager, because that is the value ROASaurus matches to the ad. TikTok can also attach UTM parameters automatically, with TikTok as the source and paid as the medium. If you use that option as well as your own template, check the preview so that each parameter appears only once. TikTok also adds its own click id, ttclid, to the landing page URL when someone clicks an ad. You do not need to add it yourself.

A naming system you can copy

Dynamic parameters copy your names into the URL. So a UTM naming system is really a system for naming campaigns, ad sets and ads. Decide it once, write it down and use it on every platform.

LevelPatternExampleEnds up in
Source (fixed)platformfacebook, tiktokutm_source
Medium (fixed)type of marketingpaidutm_medium
Campaignmarket_goal_offerus_prospecting_spring-saleutm_campaign
Ad set or ad groupaudience_agebroad_25-54utm_term
Adhook:…_creator:…_format:…hook:problem_creator:anna_format:ugcutm_content
One pattern per level, the same on Meta and TikTok. The ad name pattern lets ROASaurus group results by hook, creator and format.

The rules behind the table:

  • Lowercase for fixed values. Always facebook, never Facebook in one ad and facebook in the next.
  • No spaces. Use a hyphen inside a part (spring-sale) and an underscore between parts (us_prospecting_spring-sale).
  • The same order of parts everywhere. Market, then goal, then offer. Reports sort and filter better when every name has the same shape.
  • Only letters, numbers, hyphens, underscores and colons. Characters such as &, #, ? and = have a meaning in URLs, and a link breaks when a tool does not encode them.
  • Creative facts in the ad name. Hook, creator and format, so you can compare them later. See creative fatigue for why this helps.

With this system, a click on a Meta ad lands on a URL like this one:

Example landing page URL after a click (line breaks added)
https://yourstore.com/products/linen-shirt?utm_source=facebook&utm_medium=paid
  &utm_campaign=us_prospecting_spring-sale&utm_id=120210000000000001
  &utm_term=broad_25-54&utm_content=hook:problem_creator:anna_format:ugc
  &fbclid=IwAR2x...

Common mistakes that break UTM tracking

Spaces and mixed case

Google Analytics treats facebook and Facebook as two different sources, so one channel splits into two rows. Spaces are encoded as %20 or turned into a plus sign, depending on the tool, and filters stop matching. Use lowercase and no spaces in every value you type yourself.

Renaming a campaign after launch

Editing the parameters of live ads

On Meta, changing the URL parameters of a published ad may send its ad set back into the learning phase. Put the template in place before launch. When you duplicate an ad, check its URL parameters field before you publish the copy.

Redirects that drop the parameters

A redirect sends the visitor from one URL to another. If it does not copy the part after the question mark, the UTMs and click ids are gone before your tracking script runs. Common causes:

  • Link shorteners and some link-in-bio tools.
  • Redirects from an old product URL to a new one that do not keep the query string.
  • Country or language redirects to another store domain.
  • Landing pages on another domain that link to your shop without passing the parameters along.

For landing pages on another domain, ROASaurus can carry the visitor id, click ids and UTMs across: add the script to the funnel pages and list both domains under Settings › Linked domains. See funnels and landing pages.

Values typed by hand

One ad says paid, another paid-social, a third cpc. Each variant becomes its own row in your reports. Copy the template instead of typing it again.

Testing before launch

  1. Click through

    Open the ad preview, or make a test click, and let the landing page load completely.

  2. Read the final URL

    Check the address bar after all redirects. Every utm_ parameter and the click id (fbclid or ttclid) must still be there.

  3. Check the values

    Source and medium are lowercase, and the names are real names. A literal {{ad.name}} or __CID_NAME__ in the URL means the macro was not filled in.

  4. Check the first orders

    After the first sales, open your attribution report and confirm that the orders appear under the right campaign and ad.

How ROASaurus uses UTMs and click ids

The ROASaurus script reads the landing page URL on every page view. When the URL has a click id (fbclid, ttclid, gclid and others) or a UTM parameter, ROASaurus stores a touch for that visitor. When an order comes in, the touches inside your lookback window decide which channel, campaign and ad get the credit. Without a click id or UTM, a visit is not a touch, so direct visits never overwrite an earlier ad click.

Ad clickThe platform adds its click id, your template adds the UTMs
Landing pageThe script reads the click id and UTMs from the URL
TouchStored for the visitor: channel, campaign, ad set, ad
OrderCredited to the touches in the lookback window
ReportsAttribution by campaign, creative analytics by ad
Click ids and UTMs are read on the landing page. A redirect that removes them breaks the whole chain.
ParameterWhat ROASaurus uses it for
utm_source or a click idThe channel. Meta: an fbclid, or a source of facebook, fb, ig, instagram or meta. TikTok: a ttclid, or a source of tiktok. Upper or lower case does not matter.
utm_campaignThe campaign name in the attribution report.
utm_idThe campaign id. Ad spend from Meta and TikTok is matched to orders by campaign id or campaign name.
utm_termThe ad set or ad group.
utm_contentThe ad. Creative analytics matches it to the ad name or the ad id.
A source such as facebook_ads, without an fbclid, is not recognized as Meta and ends up under Other.

Two points matter for your template. First, revenue per creative in creative analytics is last click, matched on utm_content. If utm_content holds something other than the ad name or ad id, the ad gets spend but no revenue. Second, campaign ROAS in attribution needs the spend and the orders to match, which is why the campaign id in utm_id helps after a rename.

Click ids and UTMs do different jobs. Meta and TikTok use click ids to match the purchases you send them to the original click, and ROASaurus includes them when it sends each paid order server-side. UTMs are for your own reports. You need both. More in what server-side tracking is.

With Respect visitor consent on (the default), the script sets no visitor id for visitors who decline marketing cookies, so their ad clicks and UTMs are not linked to them. Their paid orders are still sent to your ad platforms server-side, with hashed order data. On Shopify, the order's landing page address is part of the order data, and it can include UTMs and click ids. When there is no touch from the script, for example because the visitor declined or an ad blocker stopped the script, ROASaurus uses that address in its own attribution reports. It does not send it to the ad platforms.

Sources

  1. Google Analytics Help: URL builders: Collect campaign data with custom URLs
  2. Meta Business Help Center: Specifications for dynamic URL parameters in Meta Ads Manager
  3. TikTok Ads Manager: About UTM Parameters
  4. TikTok Ads Manager: How to add URL parameters to your website URL
  5. TikTok Ads Manager: About TikTok Click ID

In ROASaurus

Keep reading

AttributionEcommerce attribution models: last click, linear and moreAttribution models for ecommerce compared: last click, first click, linear, data-driven and survey-based, worked through on one customer journey.AttributionFacebook Ads vs Shopify sales: why Ads Manager shows moreFacebook Ads vs Shopify sales: why Ads Manager reports more purchases than your store, how to reconcile the two step by step, and which number to trust.AttributionPost-purchase survey attribution: what clicks missPost-purchase survey attribution asks buyers how they found you. Learn how to write the question, handle bias and combine the answers with click data.
FAQ

Questions, answered

What UTM parameters should I use for Facebook ads?

Use utm_source=facebook and utm_medium=paid as fixed values, and Meta dynamic parameters for the rest: the campaign name in utm_campaign, the campaign id in utm_id, the ad set name in utm_term and the ad name in utm_content.

Where do I add UTM parameters in Meta Ads Manager?

In the URL parameters field of each ad. Set them before you publish, because Meta notes that changing URL parameters later may send the ad set back into the learning phase.

What are TikTok URL macros?

Placeholders that TikTok fills in when someone clicks, such as __CAMPAIGN_NAME__ for the campaign name and __CID_NAME__ for the creative name. TikTok can also attach UTM parameters automatically.

Why do my UTM campaign names not match Ads Manager?

Meta fills name parameters with the name the campaign had when the ad was first published. If you renamed the campaign later, the URL still has the old name. Match on the campaign id in utm_id instead.

Do I still need UTM parameters with server-side tracking?

Yes. Click ids let the ad platforms match purchases to clicks, but UTMs tell your own reports which campaign and ad each visit came from.

Every sale, traced to the ad that earned it

Server-side tracking, profit and lifetime value in one app. 14-day free trial, no credit card.

Start your free trial →