You just launched a marketing campaign across email, social media, and paid ads. A week later, your traffic doubled—but where did those visitors actually come from? Without proper tracking, Google Analytics might show most of them as "direct" traffic, leaving you guessing which channel drove the results.
Key Takeaways
- 1UTM parameters (utm_source, utm_medium, utm_campaign) track where traffic originates
- 2Always use lowercase and underscores for consistent data in Google Analytics
- 3The Campaign URL Builder tool generates properly formatted tracking URLs
- 4GA4 Measurement Protocol enables server-side tracking for advanced use cases
- 5Test tracking links before launching campaigns to avoid corrupted data
This is where UTM parameters come in. By adding specific tags to your URLs, you can track exactly which campaigns, platforms, and even individual links are bringing visitors to your site. This guide shows you how to set them up correctly and avoid common mistakes that corrupt your data.
What Are UTM Parameters?
Understanding UTM parameters starts with knowing their history and purpose. This section explains what UTM parameters are, how they flow into Google Analytics, and why they've remained the standard for campaign tracking for nearly two decades.
UTM (Urchin Tracking Module) parameters are tags you add to the end of any URL. When someone clicks a tagged link, Google Analytics reads these parameters and records where the visitor came from, what type of link they clicked, and which campaign it belonged to.
The name "Urchin" comes from Urchin Software Corporation, which Google acquired in 2005 to create Google Analytics. The UTM system has remained the standard for campaign tracking ever since.
https://example.com/sale?utm_source=newsletter&utm_medium=email&utm_campaign=summer_saleWithout these parameters, Google Analytics would see this visitor as "direct" traffic (if they clicked from an email client) or might attribute them to the wrong source. With UTM parameters, you know exactly that this person clicked a link in your newsletter, via email, as part of your summer sale campaign.
The Three Required Parameters
While technically only utm_source is required, you should always use all three core parameters together. Using just one or two creates incomplete data that's hard to analyze later.
The table below summarizes the three core parameters. Each serves a distinct purpose in answering the questions: where did this traffic come from, how did it get here, and why did we send it?
| Parameter | What it tracks | Examples |
|---|---|---|
utm_source | Where the traffic came from | google, facebook, newsletter |
utm_medium | What type of link it was | cpc, email, social |
utm_campaign | Which campaign it belongs to | summer_sale, black_friday |
utm_source identifies the specific platform or website sending traffic. This is the "who"—Facebook, Google, your email provider's name, a partner website, etc.
utm_medium categorizes the type of traffic. Think of this as the "how"—was it a paid click (cpc), an organic social post (social), an email link (email), or a banner ad (display)? Using consistent medium values lets you compare performance across channels.
utm_campaign groups related marketing efforts together. This is the "why"—what initiative or promotion is this link part of? Campaign names should be specific enough to identify the effort but general enough to group related activities.
Beyond these three core parameters, two optional parameters provide additional granularity for advanced tracking.
Optional Parameters for Deeper Insights
Two additional parameters let you drill down further into your data. These are especially valuable for A/B testing and paid search campaigns.
The optional parameters give you more granular attribution within campaigns:
| Parameter | What it tracks | Examples |
|---|---|---|
utm_content | Which specific link was clicked (A/B testing) | header_button, footer_link, blue_cta |
utm_term | Paid search keywords | running_shoes |
utm_content is invaluable when you have multiple links to the same page within a single campaign. For example, if your email has both a header image and a footer button linking to your sale page, utm_content tells you which one people actually click. This is also perfect for A/B testing different call-to-action text or button colors.
utm_term was originally designed to track paid search keywords. While Google Ads auto-tagging handles this automatically now, utm_term is still useful for tracking keywords from other ad platforms or for custom keyword tracking.
Real-World Example: Product Launch Campaign
Let's say you're launching a new product and promoting it across multiple channels. Here's how you might tag your URLs:
https://shop.example.com/products/shoes?utm_source=instagram&utm_medium=social&utm_campaign=spring_collection&utm_content=story_linkThis tells Google Analytics: "This visitor came from Instagram, clicked a social media link, as part of the spring collection campaign, specifically from the story link (as opposed to a bio link or feed post)."
For the same campaign on other channels, you might use:
# Email newsletter
?utm_source=newsletter&utm_medium=email&utm_campaign=spring_collection&utm_content=hero_image
# Facebook ad
?utm_source=facebook&utm_medium=cpc&utm_campaign=spring_collection&utm_content=carousel_ad
# Influencer partnership
?utm_source=influencer_jane&utm_medium=referral&utm_campaign=spring_collection
# Twitter organic post
?utm_source=twitter&utm_medium=social&utm_campaign=spring_collectionNotice the pattern: the campaign name stays consistent across channels while source and medium change. This lets you aggregate all spring collection traffic in one report, then drill down by channel. The utm_content parameter (when used) differentiates specific creatives or placements within each channel.
With this structure, you can analyze performance at multiple levels: Which platform drives the most sales? Which medium (paid vs organic social) has better ROI? Which specific ad creative or email element gets the most clicks?
Knowing the parameters is only half the battle—using them consistently is where most teams struggle. Let's cover the practices that keep your data clean.
Best Practices (And Why They Matter)
UTM tracking is only as good as your discipline in using it. This section covers the four practices that separate useful analytics data from a mess of fragmented, misleading reports.
Always Use Lowercase
UTM parameters are case-sensitive in Google Analytics. This means Facebook, facebook, and FACEBOOK appear as three completely separate sources in your reports. If your team isn't consistent, your data becomes fragmented and nearly impossible to analyze accurately.
# Bad - these show as THREE different sources in GA4
?utm_source=Facebook
?utm_source=facebook
?utm_source=FACEBOOK
# Good - always lowercase, always consistent
?utm_source=facebookThe fix is simple: establish a rule that all UTM values are lowercase, and enforce it with a URL builder tool or spreadsheet template. Cleaning up inconsistent historical data is painful—preventing it is easy.
Use Underscores, Not Spaces
Spaces in URLs get encoded as %20 or +, which makes your data ugly and harder to read in reports. Underscores or hyphens keep your campaign names clean and readable.
# Bad - spaces cause readability issues
?utm_campaign=Summer Sale 2024
# Shows as: Summer%20Sale%202024 or Summer+Sale+2024
# Good - use underscores or hyphens
?utm_campaign=summer_sale_2024
?utm_campaign=summer-sale-2024Underscores and hyphens both work well—pick one and stick with it. The key is consistency across your organization. Some teams prefer underscores because they're visually cleaner in reports; others prefer hyphens for URL readability. Either works as long as everyone uses the same convention.
Never Use UTMs on Internal Links
This is one of the most common and damaging mistakes. When you add UTM parameters to links within your own website (like navigation menus or internal promotions), you break the user's session in Google Analytics.
Here's what happens: A visitor arrives from Google organic search. They browse your site, then click an internal link with UTM parameters. Google Analytics sees the UTM parameters and starts a new session, now attributed to the internal link's source. The original Google organic attribution is lost, and your reports show inflated traffic from sources that aren't actually bringing new visitors.
Rule: Only use UTM parameters on links from external sources—emails, ads, social posts, partner websites. Never on your own site's navigation, banners, or internal links.
Create a Naming Convention Document
Before launching any campaigns, create a shared document that defines your standard values for each parameter. This prevents the chaos of one person using fb while another uses facebook.
# Example naming convention
Sources: google, facebook, instagram, twitter, linkedin, newsletter, partner_[name]
Mediums: cpc, organic, social, email, referral, display, affiliate
Campaigns: [year]_[month]_[campaign_name] (e.g., 2024_06_summer_sale)
Content: [placement]_[variant] (e.g., header_blue, sidebar_v2)A naming convention document is cheap insurance against data chaos. Create it before your first campaign, share it with everyone who builds URLs, and review it quarterly to add new sources or channels as your marketing evolves.
UTM parameters work great for website tracking, but sometimes you need to send data from places where JavaScript can't run. That's where the Measurement Protocol comes in.
GA4 Measurement Protocol
The Measurement Protocol is Google Analytics' server-side API. It lets you send events directly to GA4 without relying on the JavaScript tag. This section covers the basics: the endpoint, request format, and how to test your implementation.
UTM parameters work great for website links, but what about tracking events that happen on your server? Customer makes a purchase through your POS system? User completes a phone order? Subscription renews automatically? The Measurement Protocol lets you send these events directly to GA4 via HTTP requests.
This is powerful for connecting online and offline data, tracking server-side conversions, and sending data from systems where you can't install the GA4 JavaScript tag.
The Endpoint
All Measurement Protocol requests go to a single endpoint. You'll need your GA4 Measurement ID (starts with G-) and an API secret from your GA4 admin settings.
POST https://www.google-analytics.com/mp/collect
?measurement_id=G-XXXXXXXXXX
&api_secret=YOUR_API_SECRETTo create an API secret: GA4 Admin → Data Streams → Select your stream → Measurement Protocol API secrets → Create.
Sending an Event
The request body is JSON containing a client ID (to associate events with a user) and an array of events. Here's how to send a purchase event from different environments:
curl -X POST \
'https://www.google-analytics.com/mp/collect?measurement_id=G-XXXXXX&api_secret=YOUR_SECRET' \
-d '{
"client_id": "123456.789012",
"events": [{
"name": "purchase",
"params": {
"currency": "USD",
"value": 99.99,
"transaction_id": "T12345"
}
}]
}'Each example sends the same purchase event with identical data. The client_id is crucial—it links the server-side event to a specific user session. A 204 response means success; any 2xx response with a body means validation errors occurred.
Important: The client_id should match the GA4 client ID from the user's browser session if you want to connect server-side events to their browsing behavior. You can retrieve this from the GA cookie (_ga) or the gtag API.
Always Test First
Before sending real data, use the debug endpoint to validate your events. It returns detailed error messages instead of silently accepting bad data.
# Debug endpoint - validates without recording
https://www.google-analytics.com/debug/mp/collect?measurement_id=G-XXXXXX&api_secret=YOUR_SECRET
# Response shows validation errors like:
{
"validationMessages": [
{
"fieldPath": "events[0].params.value",
"description": "value must be a number",
"validationCode": "VALUE_INVALID"
}
]
}Common validation issues: value must be a number (not a string), event names can't start with numbers, required parameters missing. The debug endpoint catches these before they corrupt your production data.
Troubleshooting Common Issues
UTM tracking can fail silently, leaving you with misleading data. This section covers the most common problems and their solutions—use this as a diagnostic checklist when your tracking isn't working as expected.
Even with careful setup, UTM tracking can go wrong. Here are the most common problems and how to diagnose them:
The table below maps symptoms to likely causes and fixes:
| Problem | Likely Cause | How to Fix |
|---|---|---|
| UTMs not showing in reports | Redirect stripped the parameters | Test your URLs—if they redirect, ensure query strings are preserved. Many URL shorteners and redirects drop parameters by default. |
| Source shows as "(direct)" | Missing utm_source or email client blocking | Always include all three core parameters. Some email clients strip query strings—test with your actual email platform. |
| Same source appearing twice (e.g., "facebook" and "Facebook") | Inconsistent casing across team | Audit existing campaigns, standardize naming, use a URL builder with validation. |
| Sessions keep splitting unexpectedly | UTMs on internal links | Remove all UTM parameters from links within your own website. |
| Measurement Protocol events not appearing | Wrong client_id or API secret | Use debug endpoint to validate. Check that client_id format matches GA4 expectations. |
Tools for Building UTM URLs
Building UTM URLs by hand is tedious and error-prone. These tools automate the process, enforce your naming conventions, and catch mistakes before they corrupt your data.
Manually typing UTM parameters is error-prone. Use these tools to ensure consistency and catch mistakes:
- Google's Campaign URL Builder — The official tool from Google. Simple, reliable, but no team features.
- URL Editor — Visual parameter editing with encoding handled automatically.
- UTM Builder — Quick UTM generation with preset values.
For teams, consider using a shared spreadsheet with dropdown menus for source/medium/campaign values. This enforces your naming convention and creates a log of all tagged URLs.
Frequently Asked Questions
Official Documentation
- Google: Custom URL Parameters — Official guide to UTM parameters in GA4
- GA4 Measurement Protocol — Technical reference for server-side tracking
- GA4 Traffic Source Dimensions — How GA4 processes and reports traffic sources