DEV Community

Cover image for UTM parameters done right: 7 rules that keep your campaign reports clean
linkbe
linkbe

Posted on AI-assisted

UTM parameters done right: 7 rules that keep your campaign reports clean

Disclosure: I'm part of the team behind FastAnalytics. The rules below work in any analytics tool, and the builder I mention is free and needs no sign-up.

UTM parameters are the simplest tracking tool there is: five tags at the end of a link that tell your analytics where a visit came from. And yet most UTM reports end up messy, with Facebook, facebook and fb listed as three different sources, and campaigns nobody remembers creating.

The problem is never the tags. It's the lack of rules. Here are the ones that keep reports readable.


The 30-second refresher

https://example.com/pricing?utm_source=newsletter&utm_medium=email&utm_campaign=black-friday
Enter fullscreen mode Exit fullscreen mode
Parameter Answers Example
utm_source Who sent the visit newsletter, instagram, google
utm_medium What kind of channel email, social, cpc, qr
utm_campaign Which campaign or promotion black-friday, launch-2026
utm_term Paid keyword (optional) cookieless analytics
utm_content Which link or creative (optional) header-button, video-a

Rule 1: Lowercase everything

Most analytics tools treat Email and email as different values. Pick lowercase and never deviate. It's the single change that fixes the most reports.

Rule 2: Use hyphens, never spaces

black friday becomes black%20friday in the URL and looks different depending on where it was copied. Use black-friday.

Rule 3: Keep a fixed list of sources and mediums

Write it down once and share it with everyone who creates links:

Channel utm_source utm_medium
Newsletter newsletter email
Instagram bio instagram social
Instagram ads instagram paid-social
Google Ads google cpc
QR code on a flyer flyer qr
Partner blog partner-name referral

The medium matters more than it looks: many tools group traffic into channels (Email, Social, Paid…) based on it. A made-up medium like insta-story-promo lands in "Other" and disappears from your channel report.

Rule 4: Never put UTMs on internal links

A UTM on a link from your own home page to your own pricing page tells your analytics "this visit came from a new campaign". The real source (Google, the newsletter, whatever brought the person in) gets overwritten. UTMs are for links into your site from somewhere else, never between your own pages.

Rule 5: Never put personal data in a UTM

No emails, names or customer IDs in utm_content or anywhere else. URLs end up in browser history, server logs, screenshots and third-party tools. If you need to know which subscriber clicked, that's your email platform's job, not a URL parameter.

Rule 6: Check that redirects keep them

Link shorteners, http → https redirects and some CMS plugins can drop the query string. Before a campaign goes out, click the final link and look at the address bar. If the utm_ tags are gone, so is your attribution.

Rule 7: Name campaigns so you'll understand them in a year

promo2 means nothing next March. 2026-12-black-friday or launch-pricing-page will. Put the date first if you run many campaigns; reports sort nicely that way.


Build them in code (and enforce the rules automatically)

If you generate links from a script, a CMS or an email template, let code apply the rules so humans can't break them:

function utmLink(url, { source, medium, campaign, term, content }) {
  const clean = (v) =>
    String(v).trim().toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9._-]/g, "");

  const u = new URL(url);
  const params = { utm_source: source, utm_medium: medium, utm_campaign: campaign, utm_term: term, utm_content: content };

  for (const [key, value] of Object.entries(params)) {
    if (value) u.searchParams.set(key, clean(value));
  }
  return u.toString();
}

console.log(
  utmLink("https://example.com/pricing", {
    source: "Newsletter",
    medium: "Email",
    campaign: "Black Friday 2026",
  })
);
// https://example.com/pricing?utm_source=newsletter&utm_medium=email&utm_campaign=black-friday-2026
Enter fullscreen mode Exit fullscreen mode

URL and searchParams handle the encoding and keep any query string the link already had.


Or use a builder

If you'd rather not write code, our free UTM builder and checker does the same in the browser (nothing is sent or stored):

  • Build: pick where you'll share the link (Instagram bio, newsletter, Google Ads, QR code…) and it fills in source and medium for you.
  • Check: paste an existing link to see what it will report.
  • Bulk: create many links at once for a campaign.

For the full reference, with more examples, see our guide to UTM parameters.


A five-minute UTM audit

Open your analytics, go to the campaigns or sources report for the last 90 days, and look for:

  • [ ] The same source written in different ways (Facebook, facebook, fb).
  • [ ] Mediums that don't match any channel and end up in "Other".
  • [ ] Campaigns with traffic you can't explain (often a UTM on an internal link).
  • [ ] Values that look like emails or IDs.

Fix the rules, share the table, and next quarter's report will thank you.


What's the strangest utm_source you've found in a report?

Cover photo by Merakist on Unsplash.

Top comments (0)