Meta's URL tags can fill in six dynamic values: {{campaign.id}}, {{adset.id}}, {{ad.id}}, {{campaign.name}}, {{adset.name}} and {{ad.name}}. The three name macros do not read the current name. Meta stores the names in a snapshot when you first publish the object and fills the tag from that snapshot, so a campaign you rename later keeps sending its old name in utm_campaign. Put {{campaign.id}} in utm_id, keep the name for people to read, and join your ad data to your analytics data on IDs.
How URL tags work
URL tags are a field of the ad creative (url_tags in the Marketing API). You write them as key=value pairs joined by &, and Meta adds them to the ad's links. A macro goes in the value position and is replaced when the ad is shown. With an ad named summer_launch and the tag ad_name={{ad.name}}, a visitor lands with ad_name=summer_launch in the address.
How the trap shows up in your reports
A typical setup reads utm_source=facebook&utm_medium=paid_social&utm_campaign={{campaign.name}}. Then someone renames Prospecting Q3 to Prospecting - Broad. From that day:
- Meta's own reporting shows the campaign under its new name.
- Your analytics tool keeps receiving
Prospecting Q3inutm_campaign, because that is what the snapshot holds. - A report that matches the two on campaign name finds no partner for either side, and spend and sessions land on different lines.
The same happens one level down with {{adset.name}} in utm_content or utm_term.
Tag with IDs
IDs never change when you rename, so they are the stable key. A tag set that keeps both a readable name and a join key:
utm_source=facebook&utm_medium=paid_social&utm_campaign={{campaign.name}}&utm_id={{campaign.id}}&utm_content={{adset.id}}
Google's URL builder guide names utm_id as the campaign ID parameter and recommends sending it with the source, medium and campaign. In the GA4 Data API, the manual campaign ID is filled from utm_id, and sessionCampaignId covers manual campaigns as well as Google Ads campaigns. So a session tagged as above carries Meta's campaign ID in its session campaign ID.
Set the tags at the start. A tag change applies to new clicks only; sessions you already have keep whatever they arrived with.
What etlmcp's rows hold
When the Meta connector is available, each Meta row carries Meta's campaign ID and name in campaign_id and campaign_name, and the ad set's ID and name in adgroup_id and adgroup_name, next to ad_id and ad_name. Every row also has network set to meta. See the Meta connector for the full column list.
When the GA4 connector is available, it reports by sessionCampaignId and sessionCampaignName, and puts the campaign ID in campaign_id. When GA4 gives no campaign ID for a row (empty or (not set)), etlmcp keys that row on the campaign name instead. GA4's own metrics, such as sessions, arrive as extra columns; in PostgreSQL their names keep the dot, so you quote them, as in "extra.sessions".
Names in your tables are whatever Meta reported when the day was last pulled. In PostgreSQL, a run deletes that pipeline's rows for the dates it covers and writes them again, so a re-pulled day takes the name Meta returns at that time while older days keep the earlier one. Group on IDs and pick one name per ID for display.
Join Meta spend to GA4 sessions on the ID
The query below assumes a Meta table called meta_ads and a GA4 table called ga4_sessions, both written by etlmcp to PostgreSQL. It sums each side by day and campaign ID first, so the per-ad and per-source rows do not multiply each other.
WITH meta AS (
SELECT date, campaign_id, max(campaign_name) AS meta_name, sum(cost) AS cost
FROM meta_ads
GROUP BY date, campaign_id
), ga4 AS (
SELECT date, campaign_id, sum("extra.sessions") AS sessions
FROM ga4_sessions
GROUP BY date, campaign_id
)
SELECT meta.date, meta.campaign_id, meta.meta_name, meta.cost, ga4.sessions
FROM meta
LEFT JOIN ga4 USING (date, campaign_id)
ORDER BY meta.date, meta.campaign_id;
Rows where sessions is empty point to campaigns whose links lack utm_id, or whose GA4 rows fell back to a name key. Those are the ones to retag.