ETLMCPData Conveyance Works
Log in Start free
Guides

TikTok URL macros for UTMs, including Smart+

Which TikTok macro fills which UTM level, the two extra macros for upgraded Smart+ campaigns, what Auto-attach adds, and why utm_id should be the campaign ID.

TikTok names its URL macros after its own internal levels, not after the words you see in Ads Manager. __CAMPAIGN_NAME__ and __CAMPAIGN_ID__ fill the campaign, __AID_NAME__ and __AID__ fill the ad group, __CID_NAME__ and __CID__ fill the creative, and __PLACEMENT__ fills the placement. Campaigns in the upgraded Smart+ experience add a fourth level, the ad, with its own pair: __ADID_V2_NAME__ and __ADID_V2__. Put __CAMPAIGN_ID__ in utm_id, because the campaign ID is the value your TikTok rows in etlmcp are keyed on.

The macro table

TikTok swaps each macro for the real value at click time.

Macro Level Value it sends
__CAMPAIGN_NAME__ Campaign The campaign's name
__CAMPAIGN_ID__ Campaign The campaign's ID
__AID_NAME__ Ad group The ad group's name
__AID__ Ad group The ad group's ID
__ADID_V2_NAME__ Ad, upgraded Smart+ The name of the ad, the bundle of creative assets
__ADID_V2__ Ad, upgraded Smart+ The ad's ID
__CID_NAME__ Creative The creative's name
__CID__ Creative The creative's ID
__PLACEMENT__ Placement The placement type, such as TikTok or TikTok Pangle

The two traps are in the letters. AID reads like "ad ID" but is the ad group, and CID reads like "campaign ID" but is the creative. A tag such as utm_campaign=__CID__ sends creative IDs where you expected campaigns, and every ad looks like its own campaign in your analytics tool.

What changes in upgraded Smart+ campaigns

TikTok's reporting article for the upgraded Smart+ experience describes four levels: campaign, ad group, ad and creative. An ad there is a bundle of creative assets, and a creative is one video, image or text asset. The ad level is the new one, which is why it has the V2 macros.

So in an upgraded Smart+ campaign, __CID__ points at a single asset and __ADID_V2__ points at the bundle above it. TikTok labels the V2 macros for upgraded Smart+ campaigns only, so elsewhere stick to the campaign, ad group and creative macros. TikTok also notes that mobile measurement partners support three levels, so ad-level names and data from an upgraded Smart+ campaign are not reported there.

Auto-attach and what it fills in

Ads Manager has a URL Auto-attach option, switched on or off with the Auto-attach toggle under Edit below the Preview button, in the ad details where you enter the destination URL. TikTok's how-to page says it fills in the campaign source (TikTok), the medium ("Paid"), and a campaign ID and name. The how-to page does not give the exact parameter keys Auto-attach writes for the ID and the name, and does not say whether it replaces parameters you typed yourself. TikTok's best-practices page warns that a repeated parameter, such as two utm_source values, can leave a tool such as Google Analytics keeping only the last value. Before you add your own utm_source, utm_medium or utm_id on top of Auto-attach, open Preview and read the final URL: each key should appear once.

The same page flags letter case: TikTok and tiktok can count as two sources in a third-party tool. Pick one spelling and keep it on every ad.

A tag set to start from

If you write the parameters yourself under Build URL parameters, this set gives you a readable name, a join key and the two lower levels:

utm_source=tiktok&utm_medium=paid&utm_campaign=__CAMPAIGN_NAME__&utm_id=__CAMPAIGN_ID__&utm_term=__AID__&utm_content=__CID__

TikTok's own UTM page suggests utm_term for ad group or targeting details and utm_content for creative details, which is how the IDs are placed above.

Why utm_id should be the campaign ID

Google's URL builder page strongly recommends setting utm_id, the campaign ID, along with source, medium, campaign and source platform. In the GA4 Data API, sessionManualCampaignId is filled from utm_id, and sessionCampaignId covers manual campaigns too. The etlmcp GA4 connector reports by sessionCampaignId and writes it to campaign_id; when GA4 has no campaign ID for a row, it keys the row on the campaign name instead.

When the TikTok connector is available, each TikTok row holds TikTok's campaign_id and campaign_name, the ad group's adgroup_id and adgroup_name, and an ad_id and ad_name, with network set to tiktok. Rows are pulled per ad_id, and for upgraded Smart+ campaigns that ad_id is the creative, the level TikTok's reporting article maps to the API's ad_id. The bundle ID from __ADID_V2__ has no column of its own. See the TikTok connector for the full column list.

With utm_id=__CAMPAIGN_ID__, a GA4 session and a TikTok row share the same campaign_id value, so you can join them without matching names. In PostgreSQL, GA4's metrics arrive as extra columns that keep their dotted names, so you quote them. This query, run on a TikTok table tiktok_ads and a GA4 table ga4_sessions, lists TikTok campaigns that spent but have no GA4 sessions under their ID, which usually means the ads are missing utm_id or carry the wrong macro:

SELECT t.campaign_id, max(t.campaign_name) AS tiktok_name, sum(t.cost) AS cost
FROM tiktok_ads t
WHERE NOT EXISTS (
  SELECT 1 FROM ga4_sessions g
  WHERE g.campaign_id = t.campaign_id AND g."extra.sessions" > 0
)
GROUP BY t.campaign_id
HAVING sum(t.cost) > 0
ORDER BY cost DESC;

A tag change only reaches new clicks. Sessions recorded before you fixed the tag keep the value they arrived with.

Related

Sources

  1. About UTM Parameters — ads.tiktok.com, checked
  2. How to add URL parameters to your website URL in TikTok Ads Manager — ads.tiktok.com, checked
  3. Best practices when adding UTM parameters — ads.tiktok.com, checked
  4. About reporting for the upgraded Smart+ experience — ads.tiktok.com, checked
  5. URL builders: Collect campaign data with custom URLs — support.google.com, checked
  6. The dimensions and metrics you can use in Data API — developers.google.com, checked