technical-guidesUpdated 2025

URL Structure and UTM Basics: Complete Beginner's Guide

Learn URL structure fundamentals: paths, query strings, fragments. Master UTM parameter placement for perfect GA4 tracking.

8 min readtechnical-guides

You're building your first marketing campaign. Someone tells you to "add UTM parameters to the URL."

You open a URL builder. You copy-paste some parameters. You launch the campaign.

Then GA4 shows zero campaign data.

What went wrong? You don't understand URL structure. And that's okay—this guide explains everything.

🚨 Not sure what's breaking your tracking?

Run a free 60-second audit to check all 40+ ways UTM tracking can fail.

Scan Your Campaigns Free

✓ No credit card ✓ See results instantly

URL Anatomy 101

Every URL has up to 5 main parts:

Code
https://shop.com:443/products/shoes?utm_source=facebook&size=10#reviews
  ↑       ↑      ↑       ↑              ↑                           ↑
scheme  domain port    path          query string             fragment

1. Scheme: https://
2. Domain: shop.com
3. Port: :443 (usually hidden)
4. Path: /products/shoes
5. Query string: ?utm_source=facebook&size=10
6. Fragment: #reviews

For marketing campaigns, you care about:

  • Path: Where users land
  • Query string: Where UTM parameters go
  • Fragment: Optional anchor link

Part 1: The Scheme (Protocol)

Code
https://shop.com
↑
scheme

Common schemes:

  • https:// - Secure web (recommended)
  • http:// - Insecure web (avoid)
  • mailto: - Email addresses
  • tel: - Phone numbers

For campaigns: Always use https:// (more secure, better SEO).

Part 2: The Domain

Code
https://shop.com/products
       ↑
     domain

Examples:

  • shop.com
  • www.shop.com
  • subdomain.shop.com

For campaigns: Use your primary domain (match your GA4 property).

Part 3: The Path

Code
https://shop.com/products/shoes/nike-air-zoom
                ↑
              path

The path is where users land on your site:

  • / - Homepage
  • /products - Products page
  • /products/shoes - Shoes category
  • /blog/article - Blog post

For campaigns: Point to your landing page path.

Part 4: The Query String (UTM Parameters Go Here)

Code
https://shop.com/products?utm_source=facebook&utm_medium=cpc
                         ↑
                   query string starts with ?

Query String Rules

  1. Starts with ? (question mark)
  2. Parameters separated by & (ampersand)
  3. Format: key=value
  4. Example: ?color=blue&size=10&utm_source=facebook

Query String Anatomy

Code
?utm_source=facebook&utm_medium=cpc&utm_campaign=spring
↑      ↑        ↑    ↑      ↑       ↑      ↑
│      │        │    │      │       │      │
│      │        │    │      │       │      └─ value
│      │        │    │      │       └──────── key
│      │        │    │      └────────────────── separator
│      │        │    └───────────────────────── value
│      │        └────────────────────────────── key
│      └─────────────────────────────────────── separator
└────────────────────────────────────────────── starts query string

😰 Is this your only tracking issue?

This is just 1 of 40+ ways UTM tracking breaks. Most marketing teams have 8-12 critical issues they don't know about.

• 94% of sites have UTM errors

• Average: $8,400/month in wasted ad spend

• Fix time: 15 minutes with our report

✓ Connects directly to GA4 (read-only, secure)

✓ Scans 90 days of data in 2 minutes

✓ Prioritizes issues by revenue impact

✓ Shows exact sessions affected

Get Your Free Audit Report
Code
https://shop.com/products?utm_source=facebook#reviews
                                              ↑
                                          fragment

Purpose: Scroll to specific section on page.

Example HTML:

Html
<div id="reviews">Customer Reviews</div>
 
URL: shop.com/products#reviews → Scrolls to reviews section

Important: Fragment comes AFTER query string.

URL Order Matters

✅ CORRECT Order

Code
https://shop.com/products?utm_source=facebook#reviews
         1       2           3                     4

1. Domain
2. Path
3. Query string (UTMs)
4. Fragment

❌ WRONG Order

Code
https://shop.com/products#reviews?utm_source=facebook
         1       2           4          3

Problem: Fragment comes before query string
Result: UTMs become part of fragment, not sent to server

UTM Parameters Explained

The 5 UTM Parameters

Code
?utm_source=facebook      # Where traffic comes from
&utm_medium=cpc           # Marketing medium (channel)
&utm_campaign=spring2024  # Campaign identifier
&utm_content=carousel-v1  # Ad variant (optional)
&utm_term=running-shoes   # Keyword/audience (optional)

Required vs Optional

Required (always use):

  • utm_source - Traffic source (facebook, google, email)
  • utm_medium - Marketing medium (cpc, social, email, organic)
  • utm_campaign - Campaign name (spring2024, launch, retarget)

Optional (use when needed):

  • utm_content - Ad creative or link variant (banner-v1, text-link)
  • utm_term - Paid search keyword or audience (running-shoes, lookalike)

Parameter Naming Rules

Do:

  • Use lowercase: utm_source=facebook
  • Use hyphens: utm_campaign=spring-sale-2024
  • Use underscores: utm_campaign=spring_sale_2024
  • Keep it short: utm_campaign=spring24

Don't:

  • Use uppercase: utm_source=Facebook (breaks channel grouping)
  • Use spaces: utm_campaign=spring sale (breaks URL)
  • Use special chars: utm_campaign=spring&sale (breaks parsing)

Building Your First Campaign URL

Step 1: Start with Landing Page

Code
https://shop.com/products/shoes

Step 2: Add Question Mark

Code
https://shop.com/products/shoes?
                               ↑
                          Add this

Step 3: Add utm_source

Code
https://shop.com/products/shoes?utm_source=facebook

Step 4: Add utm_medium

Code
https://shop.com/products/shoes?utm_source=facebook&utm_medium=cpc
                                                    ↑
                                            Add & separator

Step 5: Add utm_campaign

Code
https://shop.com/products/shoes?utm_source=facebook&utm_medium=cpc&utm_campaign=spring2024

Step 6: (Optional) Add Fragment

Code
https://shop.com/products/shoes?utm_source=facebook&utm_medium=cpc&utm_campaign=spring2024#featured

Final URL: Complete and valid!

Common URL Structure Mistakes

Mistake 1: No Question Mark

Code
❌ shop.com/products utm_source=facebook
✅ shop.com/products?utm_source=facebook

Mistake 2: Fragment Before Query

Code
❌ shop.com/products#section?utm_source=facebook
✅ shop.com/products?utm_source=facebook#section

Mistake 3: Using & Instead of ?

Code
❌ shop.com/products&utm_source=facebook
✅ shop.com/products?utm_source=facebook

Mistake 4: Multiple Question Marks

Code
❌ shop.com/products?color=blue?utm_source=facebook
✅ shop.com/products?color=blue&utm_source=facebook

Mistake 5: Spaces in Parameters

Code
❌ shop.com/products?utm_campaign=spring sale
✅ shop.com/products?utm_campaign=spring-sale

Testing Your URL

Method 1: Browser Console

Javascript
const url = new URL('YOUR_CAMPAIGN_URL');
console.log('UTM Source:', url.searchParams.get('utm_source'));
console.log('UTM Medium:', url.searchParams.get('utm_medium'));
console.log('UTM Campaign:', url.searchParams.get('utm_campaign'));

Expected: All three should show values, not null.

Method 2: GA4 Real-Time

  1. Visit your campaign URL in incognito mode
  2. Open GA4 → Real-Time reports
  3. Look for your session with campaign attribution
  4. Verify source, medium, campaign appear correctly

Method 3: URL Validator

Paste into a URL validator tool:

  • Check for syntax errors
  • Verify length (< 420 chars for GA4)
  • Confirm all parameters detected

URL Building Best Practices

1. Use a URL Builder

Don't build manually. Use:

  • Google's Campaign URL Builder
  • Your marketing platform's builder
  • UTMGuard's validator
  • Custom team template

2. Follow Naming Conventions

Create a standard format:

Code
utm_campaign format: `{"{"}{"{"}year{"}"}{"}"}}`-`{"{"}{"{"}type{"}"}{"}"}}`-`{"{"}{"{"}detail{"}"}{"}"}}`

Examples:
2024-spring-shoes
2024-launch-prodX
2024-retarget-cart

3. Validate Before Launch

Always check: ✅ URL length < 420 characters ✅ Question mark before first parameter ✅ Fragment (if used) comes last ✅ No spaces or special characters ✅ All parameters lowercase

4. Test in GA4

Never skip testing:

  1. Visit URL in incognito
  2. Check GA4 Real-Time
  3. Verify campaign appears
  4. Confirm all parameters tracked

✅ Fixed this issue? Great! Now check the other 39...

You just fixed one tracking issue. But are your Google Ads doubling sessions? Is Facebook attribution broken? Are internal links overwriting campaigns?

Connects to GA4 (read-only, OAuth secured)

Scans 90 days of traffic in 2 minutes

Prioritizes by revenue impact

Free forever for monthly audits

Run Complete UTM Audit (Free Forever)

Join 2,847 marketers fixing their tracking daily

FAQ

What's the difference between path and query string?

Path is WHERE users land (/products). Query string is additional DATA sent with the request (?utm_source=x).

Can I have a URL with only a query string and no path?

Yes: shop.com?utm_source=facebook (path defaults to /).

Do query parameters affect SEO?

UTM parameters don't affect SEO. Google strips them when indexing. Use canonical tags to be safe.

Can I use uppercase in UTM parameters?

Technically yes, but DON'T. GA4 channel grouping is case-sensitive. Always use lowercase.

What's the maximum URL length?

Google Search supports 2,048 chars. But GA4 truncates at 420 chars. Always stay under 420.

Can I have spaces in URLs?

Spaces must be URL-encoded as %20. Better practice: use hyphens instead.

Conclusion

URL structure for UTM tracking:

Code
https://domain.com/path?utm_source=x&utm_medium=y&utm_campaign=z#anchor

Order:
1. Domain and path
2. ? (starts query string)
3. UTM parameters (& separators)
4. # (optional anchor)

Master this structure once, and every campaign URL will track perfectly.


Technical Reference: Missing Query Separator Validation Rule

UTM

Get Your Free Audit in 60 Seconds

Connect GA4, run the scan, and see exactly where tracking is leaking budget. No credit card required.

Trusted by growth teams and agencies to keep attribution clean.