How to Remove UTM Parameters From Internal Links

Learn how to find and remove UTM parameters from internal links, preserve incoming campaign tags, and check analytics journeys for attribution issues.

Published
Reading time
6 min read
How to Remove UTM Parameters From Internal Links
On this page

Campaign parameters belong on links that bring visitors to your site, not on ordinary links between its pages. To remove UTM parameters from internal links, audit the templates and CMS content that create those links, then test the resulting navigation alongside your analytics setup.

Key Takeaways

  • Keep campaign tags on appropriate incoming marketing links, but avoid copying them into internal navigation.
  • Internal campaign tags can make acquisition and attribution reports harder to interpret. Their precise effect depends on the analytics provider and configuration.
  • Remove tracking parameters selectively; other query parameters may be essential to a page or application.
  • Audit rendered links as well as templates, CMS content, redirects, and dynamically generated navigation.
  • Cleaning links is not a complete attribution fix. Validate session, consent, redirect, and cross-domain behavior separately.

An incoming campaign URL might look like this:

https://www.example.com/sale?utm_source=newsletter&utm_medium=email&utm_campaign=spring-sale

Here, the parameters describe the marketing link that brought the visitor to the site. They can help an analytics implementation identify the campaign, subject to its configuration and consent settings.

A link from that landing page to another page on the same site should normally omit those campaign parameters:

Internal link with campaign tags:
https://www.example.com/products?utm_source=newsletter&utm_medium=email&utm_campaign=spring-sale

Preferred internal link:
https://www.example.com/products

Keep a functional query parameter when the destination needs it. For example, /products?category=shoes may be a valid internal link even though /products?utm_source=homepage is not a useful way to measure an on-site promotion.

Advertisement

Why internal campaign tags complicate attribution

Campaign parameters are acquisition signals. If internal links introduce new signals during a visit, reports may no longer clearly distinguish the original traffic source from an on-site navigation or promotion. Depending on the analytics product, configuration, and reporting model, this can affect campaign information associated with page views, events, sessions, or conversions.

Do not assume that every analytics platform starts a new session whenever it sees a UTM parameter, or that every attribution report changes in the same way. Check the current documentation for your provider and the reports you use, then verify the behavior in your own implementation. Current provider documentation could not be consulted for this article, so provider-specific outcomes are intentionally not asserted here.

To measure an internal banner or promotion, consider an analytics event or the provider's on-site promotion measurement feature instead of adding acquisition tags to its destination URL. Agree on event names and reporting requirements before changing live tracking.

Audit templates and CMS content

Start with shared sources of links, then inspect individual content:

  1. Templates and components: Check headers, footers, navigation menus, cards, calls to action, and campaign banners. Look for code that copies the current page's query string into every link.
  2. CMS fields: Review menu items, reusable blocks, landing pages, rich-text links, and scheduled content. Ask editors to search for utm_source=, utm_medium=, and utm_campaign=, as well as other utm_ parameters your team uses.
  3. Link builders and redirects: Inspect URL-building functions, marketing automation rules, and redirects that add or forward campaign parameters. A redirect that preserves a query string is not automatically wrong, but it deserves review.
  4. Rendered pages: Test representative pages after scripts have run. Links generated by a CMS plugin or JavaScript may not appear in a simple source-code search.

If you have a local source checkout and ripgrep installed, search the relevant directories, substituting paths that exist in your project:

rg -n -i 'utm_[a-z0-9_]+=' ./src ./templates

This finds literal parameter assignments, including ones split across files only when each assignment appears on a single line. It will not reliably find encoded URLs, dynamically assembled parameters, database content, or links supplied by external services. Review matches rather than automatically deleting them: some may be legitimate outbound campaign URLs or test fixtures.

On a page you own or are authorized to inspect, open the browser developer console and run this read-only audit. Replace the example hostnames with the exact internal hostnames your organization controls. It reports matching links; it does not change them.

const internalHosts = new Set([
  "www.example.com",
  "shop.example.com"
]);

const matches = [];

for (const link of document.querySelectorAll("a[href]")) {
  let url;
  try {
    url = new URL(link.getAttribute("href"), document.baseURI);
  } catch {
    continue;
  }

  if (!["http:", "https:"].includes(url.protocol)) continue;
  if (!internalHosts.has(url.hostname)) continue;

  const campaignKeys = [...url.searchParams.keys()]
    .filter((key) => key.toLowerCase().startsWith("utm_"));

  if (campaignKeys.length > 0) {
    matches.push({
      origin: url.origin,
      path: url.pathname,
      campaignKeys: [...new Set(campaignKeys)]
    });
  }
}

console.table(matches);

The script checks anchors currently in the document, including relative links after they are resolved. It does not inspect form submissions, links inside inaccessible frames, or content that has not yet loaded. Run it on several page types and again after opening menus or triggering dynamic content. It matches any parameter whose name starts with utm_, case-insensitively; it does not inspect other tracking parameters.

The report excludes query values, but paths can still contain sensitive information. Avoid sharing console output until you have reviewed it. The example uses a hostname allowlist; adapt the scope if your site also needs to distinguish ports or protocols.

Advertisement

For each finding, identify where the link is created and fix that source rather than editing only the rendered page. Remove the campaign parameters from internal destinations while retaining parameters required for search, filtering, pagination, language, or application state.

Do not indiscriminately strip parameters from inbound marketing URLs. Analytics code may need to read them on the landing page, and redirects or URL rewriting can remove them before measurement occurs. Advertising click identifiers and cross-domain linker parameters are separate from UTM parameters and may be required by an integration; review them with the relevant provider's documentation before changing them.

For a controlled validation, use a staging site or an agreed test campaign:

  1. Record the expected incoming campaign URL and the internal link before the change.
  2. Arrive through the tagged URL, subject to your site's consent settings, and confirm that your analytics implementation receives the intended campaign information.
  3. Follow the cleaned internal link. Confirm that the destination loads with any functional parameters intact and that navigation events still appear as expected.
  4. Compare the relevant session and attribution reports with your provider's documented behavior. Account for reporting delays and the attribution model in use.
  5. Repeat important journeys involving redirects, single-page navigation, and any separately configured domains or subdomains.

Use synthetic test values and avoid putting personal information in campaign parameters. A successful link cleanup reduces one source of ambiguity; it does not by itself resolve consent gaps, missing events, redirect problems, or cross-domain configuration errors.

Common Mistakes

  • Tagging internal banners with UTMs: Use an on-site interaction or promotion measurement approach instead of treating internal navigation as a new acquisition campaign.
  • Removing every query parameter: This can break functional URLs and measurement integrations. Classify parameters before changing them.
  • Cleaning only templates: CMS fields, plugins, redirects, and scripts can reintroduce tagged links.
  • Assuming all providers handle tags identically: Verify the specific session and attribution behavior for your implementation.
  • Deleting tags from incoming links: This may prevent the original campaign from being recorded.

Best Practices

Document which hostnames count as internal, which query parameters are permitted in internal links, and who owns exceptions. Add a link audit to content review and release checks, and periodically scan rendered pages as well as source files. Give editors a separate, agreed method for measuring on-site promotions.

Conclusion

Keep acquisition tags on the incoming links that need them, and use clean internal navigation URLs unless a documented integration requires otherwise. Fix links at their source and validate the full journey in your analytics implementation; link cleanup is only one part of reliable attribution.

What would your domain sell for?

A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.