Canonical URL containing tracking parameters
What Is This Issue
This issue checks whether canonical URLs contain tracking or marketing parameters (like utm_source, fbclid, or gclid) that should not be part of the canonical version of a page.
A canonical URL passes this check if it:
- Points to a clean URL without any tracking parameters
- Contains only the essential URL path and parameters that define the page content
A canonical URL fails if it:
- Contains UTM parameters (
utm_source,utm_medium,utm_campaign, etc.) - Contains social media tracking parameters (
fbclid,gclid) - Contains referral tracking parameters (
ref,source)
Example:
- Passing:
<link rel="canonical" href="https://example.com/shoes"> - Failing:
<link rel="canonical" href="https://example.com/shoes?utm_source=facebook&utm_medium=social">
Why Is This Important
Canonical URLs with tracking parameters negatively impact SEO:
-
Duplicate content: Tracking parameters create unique URLs that search engines may index separately from the clean version, causing duplicate content issues.
-
Indexability: URLs with tracking parameters may appear in search results instead of the clean canonical version, confusing users and diluting SEO signals.
-
Crawl budget waste: Search engine crawlers may waste resources crawling and indexing multiple versions of the same page with different tracking parameters.
-
Link equity dilution: Inbound links with tracking parameters may not consolidate properly to the canonical page, reducing ranking potential.
Resolving this issue improves the overall SEO health score by ensuring search engines index the correct, clean version of each page and consolidate all ranking signals to that URL.
How XeoPix Detects This
XeoPix follows a simple detection process to identify canonical URLs with tracking parameters:
-
HTML parsing: The crawler parses the raw HTML
<head>section of each page and locates the first<link rel="canonical">tag. -
Canonical URL extraction: The system extracts the
hrefattribute value from the canonical tag. -
URL normalization: The canonical URL is normalized to ensure consistent parsing (resolving relative URLs, normalizing the path).
-
Parameter analysis: The system parses the query string of the canonical URL and extracts all parameter keys.
-
Tracking parameter detection: The extracted parameter keys are checked against a list of known tracking and marketing parameters:
- UTM parameters:
utm_source,utm_medium,utm_campaign,utm_term,utm_content - Social media parameters:
fbclid,gclid - Referral parameters:
ref,source,from
- UTM parameters:
-
Issue triggering: An issue is raised if any tracking parameters are found in the canonical URL.
How To Fix
-
Audit all canonical tags on the site. Crawl the entire site and extract canonical URLs from each page. Check each canonical URL for tracking parameters.
-
Remove tracking parameters from canonical URLs. Ensure the
hrefattribute in the canonical tag contains only the clean, parameter-free URL or only parameters that define the page content (not tracking parameters). -
Use clean, absolute URLs in canonical tags. Always use the full absolute URL without any analytics or marketing parameters:
<link rel="canonical" href="https://example.com/shoes" /> -
Check URL parameters in canonical tags. Be aware that some parameters are legitimate (like
?page=2for pagination) while others are not. Only remove tracking and marketing parameters. -
Verify the fix via re-crawl. After implementing clean canonical URLs, re-crawl the site to confirm that canonical tags no longer contain tracking parameters.
What We Store
Storage Level
Page Level
Database Table / Prisma Model
PageUrlParameterAudit
Fields Used
| Field | Type | Description |
|---|---|---|
| queryParamKeys | String[] | List of query parameter keys detected in the URL |
Detection Dependencies
- HTML Document
- HTTP Response
Examples
Example 1: UTM Parameters in Canonical URL
Scenario: A blog post shared on social media with UTM tracking parameters.
Problematic state (failing):
<link
rel="canonical"
href="https://example.com/blog/post?utm_source=twitter&utm_medium=social&utm_campaign=spring_sale"
/>Corrected state (passing):
<link rel="canonical" href="https://example.com/blog/post" />Example 2: Social Media Tracking Parameter
Scenario: A product page with Facebook click tracking parameter.
Problematic state (failing):
<link
rel="canonical"
href="https://example.com/products/shoes?fbclid=IwAR0example"
/>Corrected state (passing):
<link rel="canonical" href="https://example.com/products/shoes" />Example 3: Referral Tracking Parameter
Scenario: A landing page with referral source tracking.
Problematic state (failing):
<link
rel="canonical"
href="https://example.com/landing?ref=newsletter&source=email"
/>Corrected state (passing):
<link rel="canonical" href="https://example.com/landing" />Unit Test
Test File
__tests__/seo-audit-checks/urlParameterAudit/issue-218-canonical-contain-clean.test.js
Purpose
Validates that canonical URLs do not contain tracking or marketing parameters (utm_source, utm_medium, utm_campaign, utm_term, utm_content, fbclid, gclid, msclkid).
Tested Function
runUrlParameterAudit from toggleGroups/urlParameterAudit.js
Issue Information
- Issue Number: 218
- Issue Code:
canonical_contain_clean - Toggle Group:
urlParameterAudit
Test Scenarios
Positive Test Cases
- Canonical URL is not present — the page has no
<link rel="canonical">tag, so no tracking parameter analysis is performed. - Canonical URL has no tracking parameters — the canonical URL (
https://example.com/products) contains no query parameters at all. - Canonical URL has non-tracking parameters — the canonical URL contains query parameters (
filter=red&sort=price) that are not in the tracking parameters list.
Negative Test Cases
- Canonical URL contains utm_source parameter — the canonical URL includes
utm_source=google. - Canonical URL contains multiple utm parameters — the canonical URL includes
utm_source,utm_medium, andutm_campaign. - Canonical URL contains fbclid parameter — the canonical URL includes
fbclid=12345. - Canonical URL contains gclid parameter — the canonical URL includes
gclid=abc123. - Canonical URL contains msclkid parameter — the canonical URL includes
msclkid=xyz789. - All tracking parameters combined — the canonical URL includes all 8 tracking parameters (
utm_source,utm_medium,utm_campaign,utm_term,utm_content,fbclid,gclid,msclkid) simultaneously.
Edge Cases
- Case-insensitive tracking parameter detection — tracking parameters in uppercase (
UTM_SOURCE,UTM_MEDIUM) are still correctly detected. - Include recommendation in detected issue — when the issue is detected, the
recommendationfield contains"Canonical URLs should not contain marketing or tracking parameters". - Empty HTML — passing an empty HTML string does not throw an error.
- Malformed HTML — passing unclosed or broken HTML tags does not throw an error.
- Cache validation — calling
runUrlParameterAuditmultiple times with the same context does not duplicate issues; results are correctly cached.
Expected Outcome
Fail
The issue should be reported when the canonical URL contains one or more tracking/marketing parameters.
When reported, the issue includes:
- A
messageof"Canonical URL contains tracking parameters" - The
canonicalUrlwith the tracking parameters - A
trackingParamsFoundarray listing the detected tracking parameters - A
recommendationsuggesting canonical URLs should not contain marketing or tracking parameters
Pass
The issue should not be reported when:
- No canonical URL is present, or
- The canonical URL has no query parameters at all, or
- The canonical URL only has non-tracking query parameters.
Validation
- Correct issue detection for each individual tracking parameter
- Correct issue detection when all tracking parameters are combined
- No issue detection when canonical URL is absent, clean, or has non-tracking parameters
- Case-insensitive detection of tracking parameter names
- Recommendation field is included in detected issues
- Graceful handling of empty and malformed HTML
- Cache behaviour prevents duplicate issue entries on repeated calls
Related Production Files
toggleGroups/urlParameterAudit.jsissueCodes.jsutils/issues.js
Coverage Summary
- Covers all positive scenarios: no canonical, clean canonical, non-tracking parameters
- Covers individual detection of all 8 tracking parameters (
utm_source,utm_medium,utm_campaign,utm_term,utm_content,fbclid,gclid,msclkid) - Covers combined detection of all tracking parameters simultaneously
- Covers case-insensitive parameter matching
- Covers recommendation field validation
- Covers error resilience: empty HTML, malformed HTML
- Covers cache deduplication behaviour
References
- Google Search Central — Consolidate Duplicate URLs (Canonical) — Google Search Central
- Google Search Central — URL Structure — Google Search Central
- Ahrefs — URL Parameters SEO Guide — Ahrefs