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.
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.
Table of contents
- The Problem: UTMs as Folder Paths
- What You Built
- What GA4 Expects
- Why This Happens: URL Structure Confusion
- URL Anatomy Review
- The Mistake
- How This Mistake Happens
- Scenario 1: WordPress Pretty Permalinks
- Scenario 2: Misunderstanding REST API Patterns
- Scenario 3: Custom CMS URL Rewriting
- Scenario 4: Manual URL Building Mistakes
- The Fix
- Step 1: Identify Path-Based UTMs
- Step 2: Convert to Query String Format
- Step 3: Update Active Campaigns
- Step 4: Test in GA4
- Real Example: WordPress Site Migration
- Technical: Path vs Query String
- How Browsers Parse URLs
- Where GA4 Looks for UTMs
- Server-Side Detection
- FAQ
- Can I use both path and query string for UTMs?
- What if my CMS forces path-based URLs?
- Do REST APIs use path-based parameters?
- Can I customize how GA4 reads UTMs?
- What if I already have thousands of path-based URLs published?
- Does this affect SEO?
- Conclusion
🚨 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
https://shop.com/products/utm_source/facebook/utm_medium/cpc/utm_campaign/spring2024
↑
UTMs in path structure
What GA4 Expects
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
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":
❌ 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
How This Mistake Happens
Scenario 1: WordPress Pretty Permalinks
WordPress allows custom URL structures:
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:
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:
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:
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:
❌ 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):
shop.com/products/utm_source/facebook/utm_medium/cpc/utm_campaign/spring
After (working):
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
- Visit corrected URL in incognito browser
- Open GA4 → Real-Time reports
- 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):
blog.com/article?utm_source=newsletter&utm_medium=email&utm_campaign=weekly
After migration (broken):
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:
- Changed permalink structure back to default
- Used URL rewrite rules to redirect old URLs:
# .htaccess rewrite rule
RewriteRule ^article/utm_source/([^/]+)/utm_medium/([^/]+)/utm_campaign/([^/]+)/?$ /article?utm_source=$1&utm_medium=$2&utm_campaign=$3 [R=301,L]- 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
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
// 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:
# 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
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:
❌ 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