Skip to Content

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:

  1. HTML parsing: The crawler parses the raw HTML <head> section of each page and locates the first <link rel="canonical"> tag.

  2. Canonical URL extraction: The system extracts the href attribute value from the canonical tag.

  3. URL normalization: The canonical URL is normalized to ensure consistent parsing (resolving relative URLs, normalizing the path).

  4. Parameter analysis: The system parses the query string of the canonical URL and extracts all parameter keys.

  5. 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
  6. Issue triggering: An issue is raised if any tracking parameters are found in the canonical URL.

How To Fix

  1. 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.

  2. Remove tracking parameters from canonical URLs. Ensure the href attribute in the canonical tag contains only the clean, parameter-free URL or only parameters that define the page content (not tracking parameters).

  3. 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" />
  4. Check URL parameters in canonical tags. Be aware that some parameters are legitimate (like ?page=2 for pagination) while others are not. Only remove tracking and marketing parameters.

  5. 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

FieldTypeDescription
queryParamKeysString[]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

  1. Canonical URL is not present — the page has no <link rel="canonical"> tag, so no tracking parameter analysis is performed.
  2. Canonical URL has no tracking parameters — the canonical URL (https://example.com/products) contains no query parameters at all.
  3. 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

  1. Canonical URL contains utm_source parameter — the canonical URL includes utm_source=google.
  2. Canonical URL contains multiple utm parameters — the canonical URL includes utm_source, utm_medium, and utm_campaign.
  3. Canonical URL contains fbclid parameter — the canonical URL includes fbclid=12345.
  4. Canonical URL contains gclid parameter — the canonical URL includes gclid=abc123.
  5. Canonical URL contains msclkid parameter — the canonical URL includes msclkid=xyz789.
  6. 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

  1. Case-insensitive tracking parameter detection — tracking parameters in uppercase (UTM_SOURCE, UTM_MEDIUM) are still correctly detected.
  2. Include recommendation in detected issue — when the issue is detected, the recommendation field contains "Canonical URLs should not contain marketing or tracking parameters".
  3. Empty HTML — passing an empty HTML string does not throw an error.
  4. Malformed HTML — passing unclosed or broken HTML tags does not throw an error.
  5. Cache validation — calling runUrlParameterAudit multiple 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 message of "Canonical URL contains tracking parameters"
  • The canonicalUrl with the tracking parameters
  • A trackingParamsFound array listing the detected tracking parameters
  • A recommendation suggesting 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
  • toggleGroups/urlParameterAudit.js
  • issueCodes.js
  • utils/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

Last updated on