troubleshootingUpdated 2025

UTM Parameters in URL Path: Why GA4 Ignores Them

Your UTMs are in the URL path instead of query string. GA4 can't read them. Here's why it happens and how to fix it.

7 min readtroubleshooting

You built a campaign URL. You copied it from your URL builder. You launched ads across Facebook.

One week later: Zero campaign data in GA4.

You check the URL and see your UTM parameters... but they're in the URL path, not the query string.

🚨 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

The Problem: UTMs as Folder Paths

What You Built

Code
https://shop.com/products/utm_source/facebook/utm_medium/cpc/utm_campaign/spring2024
                        ↑
                UTMs in path structure

What GA4 Expects

Code
https://shop.com/products?utm_source=facebook&utm_medium=cpc&utm_campaign=spring2024
                         ↑
                UTMs in query string

The difference: Path vs query string.

Result: GA4 looks for UTM parameters in the query string (after ?). If they're in the path, GA4 never sees them.

Why This Happens: URL Structure Confusion

URL Anatomy Review

Code
https://shop.com/products?utm_source=facebook
                ↑       ↑        ↑
              domain   path    query string

Path: Where the page lives (/products) Query string: Additional data sent with request (?utm_source=facebook)

The Mistake

Some CMS platforms or URL builders allow "pretty URLs" or "SEO-friendly URLs":

Code
❌ WRONG (path-based):
shop.com/products/utm_source/facebook/utm_medium/cpc

✅ CORRECT (query-based):
shop.com/products?utm_source=facebook&utm_medium=cpc

Why path-based doesn't work:

  • GA4 JavaScript looks for window.location.search (query string)
  • UTMs in path are part of window.location.pathname
  • GA4's analytics script never checks the path for UTMs

😰 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

How This Mistake Happens

WordPress allows custom URL structures:

Code
Settings → Permalinks → Custom Structure:
/%postname%/utm_source/%utm_source%/utm_medium/%utm_medium%/

Result:
blog.com/article/utm_source/facebook/utm_medium/social/

Problem: This creates physical folder structures, not query parameters.

Scenario 2: Misunderstanding REST API Patterns

Developers familiar with REST APIs might think:

Code
API pattern:
api.com/users/123/posts/456

Applied to UTMs (WRONG):
shop.com/products/123/utm_source/facebook

This doesn't work for analytics tracking. UTMs must be in query string.

Scenario 3: Custom CMS URL Rewriting

Some CMS platforms rewrite URLs for SEO:

Code
Original: shop.com?product=shoes&utm_source=facebook
Rewritten: shop.com/product/shoes/utm_source/facebook

Problem: Rewrite rules move UTMs into path, breaking tracking.

Scenario 4: Manual URL Building Mistakes

When building URLs manually:

Code
Base URL: shop.com/products
UTM params: utm_source=facebook&utm_medium=cpc

❌ Wrong concatenation:
shop.com/products/utm_source=facebook&utm_medium=cpc

✅ Correct:
shop.com/products?utm_source=facebook&utm_medium=cpc

The Fix

Step 1: Identify Path-Based UTMs

Check your campaign URLs. Do they look like:

Code
❌ Path-based (wrong):
shop.com/page/utm_source/facebook
shop.com/page/source/facebook/medium/cpc
shop.com/page/facebook/cpc/spring2024

✅ Query-based (correct):
shop.com/page?utm_source=facebook
shop.com/page?utm_source=facebook&utm_medium=cpc
shop.com/page?utm_source=facebook&utm_medium=cpc&utm_campaign=spring2024

Step 2: Convert to Query String Format

Transform path-based UTMs:

Before (broken):

Code
shop.com/products/utm_source/facebook/utm_medium/cpc/utm_campaign/spring

After (working):

Code
shop.com/products?utm_source=facebook&utm_medium=cpc&utm_campaign=spring

Key changes:

  • Remove folder slashes /
  • Add question mark ? before first parameter
  • Connect parameters with ampersand &
  • Use equal signs = for key-value pairs

Step 3: Update Active Campaigns

Replace broken URLs in:

  • Social media ads
  • Email campaigns
  • QR codes
  • Partner links

Step 4: Test in GA4

  1. Visit corrected URL in incognito browser
  2. Open GA4 → Real-Time reports
  3. Verify campaign appears with correct attribution

Real Example: WordPress Site Migration

Company: Content blog monetized with affiliate links Problem: Site migration moved UTMs into path structure

Before migration (working):

Code
blog.com/article?utm_source=newsletter&utm_medium=email&utm_campaign=weekly

After migration (broken):

Code
blog.com/article/utm_source/newsletter/utm_medium/email/utm_campaign/weekly

What happened:

  • Developer enabled "pretty permalinks"
  • Permalink structure: /%postname%/%utm_source%/%utm_medium%/%utm_campaign%/
  • 10,000+ published URLs with UTMs in path
  • Zero campaign tracking for 3 months

Investigation:

  • GA4 showed 100% "Direct" traffic
  • Server logs showed correct paths being accessed
  • Realized UTMs were in path, not query string

Fix:

  1. Changed permalink structure back to default
  2. Used URL rewrite rules to redirect old URLs:
Apache
# .htaccess rewrite rule
RewriteRule ^article/utm_source/([^/]+)/utm_medium/([^/]+)/utm_campaign/([^/]+)/?$ /article?utm_source=$1&utm_medium=$2&utm_campaign=$3 [R=301,L]
  1. Updated all campaign URLs to use query string format

Result:

  • Campaign tracking restored
  • 3 months of historical data couldn't be recovered
  • Going forward: 100% attribution accuracy

Technical: Path vs Query String

How Browsers Parse URLs

Javascript
const url = 'https://shop.com/products/utm_source/facebook?other=value';
 
console.log(url.pathname);  // "/products/utm_source/facebook"
console.log(url.search);    // "?other=value"

GA4 reads: url.search (query string) GA4 ignores: url.pathname (path)

Where GA4 Looks for UTMs

Javascript
// GA4 analytics.js extracts UTMs from query string only
const params = new URLSearchParams(window.location.search);
const source = params.get('utm_source');
const medium = params.get('utm_medium');
const campaign = params.get('utm_campaign');

If UTMs aren't in query string → GA4 returns null.

Server-Side Detection

Your server can read path-based UTMs, but GA4 can't:

Python
# Server-side (Flask example) - can read path
@app.route('/products/utm_source/<source>/utm_medium/<medium>')
def product_page(source, medium):
    print(f"Source: `{"{"}{"{"}source{"}"}{"}"}}`, Medium: `{"{"}{"{"}medium{"}"}{"}"}}`")  # Server sees it
    # But GA4 JavaScript won't

✅ 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

Can I use both path and query string for UTMs?

No. GA4 only reads query string parameters. Path-based UTMs are invisible to analytics.

What if my CMS forces path-based URLs?

Use URL rewrite rules to convert path-based to query-based, or change CMS URL settings.

Do REST APIs use path-based parameters?

Yes, but APIs are different from analytics tracking. GA4 requires query string parameters.

Can I customize how GA4 reads UTMs?

Technically yes, with custom JavaScript, but it's complex and error-prone. Use query string format instead.

What if I already have thousands of path-based URLs published?

Use .htaccess or nginx rewrite rules to redirect path-based URLs to query-based equivalents.

Does this affect SEO?

No. Search engines handle query parameters correctly. Use canonical tags if needed.

Conclusion

UTM parameters in URL path won't track in GA4. They must be in the query string.

URL structure:

Code
❌ WRONG (path):  shop.com/page/utm_source/facebook
✅ CORRECT (query): shop.com/page?utm_source=facebook

Key points:

  • GA4 only reads query string (after ?)
  • Path-based UTMs are invisible to analytics
  • Convert path format to query string format
  • Use ? before first parameter, & between parameters

Fix once, and all future campaigns will track correctly.


Technical Reference: UTM in Path 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.