Sub topic 13
Attribution and Tagging Links with UTM Parameters
This chapter assumes you know what impressions, reach, engagement, conversion and a funnel are. It also assumes you have seen a web analytics report such as Google Analytics. You do not need to write code, though two short examples are included.
Earlier chapters set goals and KPIs and described paid social. This chapter covers how to connect those social activities to visits, leads and revenue. The main tool is the UTM parameter, and the main difficulty is that B2B and B2C buyers leave very different trails.
Why social attribution is hard
Attribution is the practice of assigning credit for a result (a lead, a sale) to the marketing touches that led to it. Social media makes this harder than search or email for several reasons:
- Much social influence is invisible. A buyer reads a post, never clicks, and later types your name into a search engine. Analytics records that visit as organic search or direct traffic.
- In-app browsers and apps can strip or hide referrer data, so a visit arrives as "direct" even though it came from a post.
- Private sharing, such as messaging apps and group chats, moves links out of public view. This is often called dark social.
- Several people may be involved in one decision, which is the usual case in B2B.
Because of this, you should not expect social reports to match the real influence of social. Your job is to make the trackable part as clean as possible and to add other signals for the rest.
What UTM parameters are
UTM parameters are short labels added to the end of a URL. They are named after Urchin Tracking Module, the analytics product that introduced them. When someone clicks the link, your web analytics tool reads the labels and files the visit under the source, medium and campaign you chose.
There are five standard parameters:
| Parameter | Required | Answers the question | Example value |
|---|---|---|---|
| `utm_source` | Yes | Which platform or site sent the visit? | `linkedin` |
| `utm_medium` | Yes | What type of channel is it? | `paid_social` |
| `utm_campaign` | Yes | Which campaign is this part of? | `q3_webinar_series` |
| `utm_content` | No | Which creative or variant was clicked? | `cfo_carousel` |
| `utm_term` | No | Which keyword or audience was targeted? | `finance_directors` |
Google Analytics 4 treats source, medium and campaign as the core set. Content and term are optional and are useful for comparing creatives and audiences.
A fully tagged link looks like this:
https://example.com/webinar?utm_source=linkedin&utm_medium=paid_social&utm_campaign=q3_webinar_series&utm_content=cfo_carouselEverything after the ? is read by analytics. The page itself loads normally. Your analytics report can now say that the CFO carousel ad on LinkedIn, in the Q3 webinar series, produced a given number of visits and registrations.
Building a naming convention
The parameters only help if everyone uses them the same way. Analytics tools treat LinkedIn, linkedin and Linkedin as different values, so one platform can appear as three rows in a report. Agree on a convention and write it down.
Good rules:
- Use lowercase only.
- Use underscores instead of spaces, because spaces become
%20in the URL and look messy. - Choose a fixed list of
utm_mediumvalues and do not add to it casually. Examples:organic_social,paid_social,influencer,employee_advocacy,email. - Put a pattern in
utm_campaign, such asquarter_theme(q3_webinar_series). - Never put personal data, such as an email address or a name, in any parameter. URLs are stored in logs, shared and sometimes made public.
- Keep a shared spreadsheet or a link builder tool as the single source of truth for what you have created.
A useful extra step is to keep the values of utm_source aligned with platform names (linkedin, instagram, tiktok, youtube, x) so that reports can be compared across campaigns.
Generating tagged links consistently
Typing links by hand causes errors. This short Python script builds a tagged URL, applies the lowercase and underscore rules, and keeps any existing query string on the link.
from urllib.parse import urlencode, urlparse, urlunparse, parse_qsl
def clean(value: str) -> str:
"""Lowercase a value and replace spaces and hyphens with underscores."""
return value.strip().lower().replace(" ", "_").replace("-", "_")
def tag_url(url: str, source: str, medium: str, campaign: str,
content: str = "", term: str = "") -> str:
"""Return the URL with UTM parameters added."""
parts = urlparse(url)
query = dict(parse_qsl(parts.query))
query["utm_source"] = clean(source)
query["utm_medium"] = clean(medium)
query["utm_campaign"] = clean(campaign)
if content:
query["utm_content"] = clean(content)
if term:
query["utm_term"] = clean(term)
return urlunparse(parts._replace(query=urlencode(query)))
print(tag_url(
"https://example.com/webinar",
source="LinkedIn",
medium="paid social",
campaign="Q3 Webinar Series",
content="CFO carousel",
))The output is the same link as the example above, with the parameters in the order they were added.
What to tag and what not to tag
Tag every link you control that points from social to a page you own. That includes post links, ad links, link-in-bio pages, creator links and employee-shared links.
Do not tag links that stay inside your own site. If a visitor clicks an internal link that carries UTM values, many analytics setups start a new session and overwrite the original source. A social visit then gets recorded as coming from your own banner or menu, and the true source is lost.
Also note that some platforms shorten or wrap links. LinkedIn, X and others may replace your URL with a short form, but the destination and parameters usually survive. Always click your own tagged link once before launch and confirm it appears in your analytics real-time report with the right labels.
B2B and B2C attribution compared
The mechanics are the same for both models. The difficulty differs because the buying process differs.
| Aspect | Typical B2B | Typical B2C |
|---|---|---|
| Sales cycle | Weeks to many months | Minutes to a few weeks |
| People involved | Buying committee | Usually one person or household |
| Conversion that analytics sees | Form fill, demo request, webinar sign-up | Purchase, add to cart, app install |
| Closing event | Often offline, in a CRM | Often on the website or in the app |
| Main attribution risk | Credit lost across a long chain of touches | Credit lost to cross-device and in-app browsing |
| Most useful extra signal | CRM opportunity and revenue data | Promo codes, post-purchase surveys, platform conversion tracking |
B2B: connect tags to the CRM
In B2B, the web visit is rarely the end. A lead fills in a form, a salesperson qualifies it, and a deal may close six months later. If the UTM values disappear at the form, you can report on leads but never on revenue.
The usual fix is to capture UTM values in hidden form fields, so that source, medium, campaign and content are saved on the contact record in the CRM. The CRM can then show opportunities and closed revenue by campaign. Two details matter:
- Store the first-touch values (the first campaign that brought the person) separately from the latest-touch values. Otherwise a later email click overwrites the social origin.
- Record values at the account level where possible. Several people from one company may touch different posts, and account-level reporting shows the combined effect.
B2C: shorter paths, more leakage
In B2C, the path is short, so UTM-tagged last-click reports are often a fair first approximation. The trouble is leakage. People see a TikTok video on a phone, then buy later on a laptop. Tagging does not follow them across devices. Complement it with platform pixels or conversion APIs, discount codes tied to creators, and a "how did you hear about us?" question at checkout.
Attribution models
An attribution model is the rule that decides how credit is shared across touches.
- First touch gives all credit to the first interaction. It favors awareness channels such as social.
- Last touch gives all credit to the final interaction before conversion. It favors search and email.
- Linear splits credit equally.
- Position-based (U-shaped) gives most credit to the first and last touches and a little to those in between.
- Data-driven models use statistical analysis of many conversion paths. They need enough volume to be reliable.
B2B teams with long cycles and low volumes usually do better with first-touch and multi-touch views plus pipeline reporting than with a statistical model. B2C teams with high volume can use data-driven models and test incremental lift, for example by running a campaign in some regions and holding it back in others.
Metrics that connect to the tags
Tagging lets you move from platform metrics to business metrics. Engagement rate is one platform metric that is easy to compute:
def engagement_rate(interactions: int, impressions: int) -> float:
"""Return engagement rate as a percentage of impressions."""
if impressions == 0:
return 0.0
return interactions / impressions * 100
print(engagement_rate(interactions=150, impressions=10000)) # 1.5This gives one comparable number across posts. It says nothing about whether the audience was the right one or whether it led to revenue. B2B teams should weigh it against pipeline measures such as leads by campaign, cost per qualified lead and influenced opportunities. B2C teams can weigh it against conversion rate, cost per acquisition and revenue per visit.
Common errors
- Inconsistent capitalization or spelling, which splits one channel across many report rows.
- Tagging internal links, which overwrites session source.
- Using
utm_medium=socialfor everything, which hides the difference between organic, paid and creator traffic. - Forgetting to tag employee and creator links, so advocacy results show as direct traffic.
- Reporting only last-click results and concluding that social "does not convert."
- Putting personal data in a URL.
- Changing naming rules mid-quarter, which breaks comparisons.
Exercise
A B2B software company shares a webinar link in a LinkedIn post, in a paid LinkedIn carousel, and through five employees' personal posts. All links use utmsource=linkedin and utmmedium=social. Last month the report showed 400 visits from "linkedin / social" and the team cannot tell which activity worked. How should the tags change, and what must happen at the registration form so that the sales team can later see revenue by campaign?
Show answer
Keep utmsource=linkedin for all, but give each activity its own utmmedium: organicsocial for the company post, paidsocial for the carousel, and employeeadvocacy for the employee links. Use the same utmcampaign (for example q3webinarseries) and use utmcontent to separate variants, such as cfocarousel or an employee identifier that is not personal data (for example a team code). At the form, capture the UTM values in hidden fields and save them on the CRM contact (first touch kept separately from latest touch). The CRM can then link opportunities and closed revenue back to each medium and campaign.
Exercise
A consumer skincare brand sees most purchases credited to "direct" and "search," yet sales rise after each TikTok creator campaign. Name two actions that would recover some of the social influence.
Show answer
Possible answers include: give each creator a unique tagged link and discount code so purchases can be tied to them; add a "how did you hear about us?" question at checkout; use the platform's conversion tracking (pixel or conversion API); and run a regional hold-out test to measure incremental lift. Any two of these are correct.