Sub topic 13
Tag Campaign Links with UTM Parameters
This chapter assumes you have a published or draft landing page URL, you know your campaign goal from the earlier chapters, and you can edit links in an email tool, ad platform, or social post.
What UTM parameters do
UTM parameters are labels added to the end of a URL. Analytics tools read them and record where each visit came from. Without them, much of your traffic shows up as "direct" or "referral", and you cannot tell which link produced a lead.
The page itself does not change. The labels sit in the query string, which is the part of the URL after the ?.
The five standard parameters
| Parameter | Answers | Example |
|---|---|---|
| `utm_source` | Which site or sender? | `newsletter` |
| `utm_medium` | Which kind of channel? | `email` |
| `utm_campaign` | Which campaign? | `spring_sale` |
| `utm_content` | Which link or variant? | `hero_button` |
| `utm_term` | Which paid keyword? | `landing_page_builder` |
Source, medium, and campaign are the core three. Use utm_content to tell two links in the same message apart. Use utm_term only for paid search.
A worked example
https://www.example.com/spring-sale?utm_source=newsletter&utm_medium=email&utm_campaign=spring_sale&utm_content=hero_buttonThis link says the visit came from the newsletter, through email, for the spring sale campaign, by clicking the hero button. Each pair is name=value, and pairs are joined with &.
Naming rules that prevent messy reports
Analytics tools treat values as exact text. Email, email, and e-mail become three separate rows.
- Use lowercase only.
- Use underscores instead of spaces.
- Keep a short list of allowed values for
utm_medium, such asemail,social,cpc, andreferral. - Record every tagged link in a shared spreadsheet with its destination and date.
Also check that the builder does not strip the query string when it redirects, for example from http to https or from a bare domain to www. Click a tagged link and confirm the parameters are still in the address bar.
Do not tag internal links
Use UTM tags only on links that bring people to your page from outside. If you tag a link on your own site, the visit starts a new session and overwrites the original source. You then lose the information you wanted.
Passing UTM values into the lead form
Analytics shows visit counts, but you may also want each lead to record its campaign. Add hidden fields named utm_source, utm_medium, and utm_campaign to the form. Then paste this snippet into the builder's custom code area, placed after the form:
const params = new URLSearchParams(window.location.search);
['utm_source', 'utm_medium', 'utm_campaign'].forEach(function (name) {
const field = document.querySelector('input[name="' + name + '"]');
if (field && params.has(name)) {
field.value = params.get(name);
}
});The script reads the URL, finds each hidden field by its name attribute, and fills it in. If a field stays empty, the usual causes are a mismatch between the field name and the parameter name, or a script that runs before the form exists.
Exercise
Your newsletter has two links to the same page, one in the hero image and one in the footer. Write the two values you would use for utm_content, and say which other parameters stay the same.
Show answer
For example hero_image and footer_link. The utm_source, utm_medium, and utm_campaign values stay the same, so both links count toward one campaign while the reports show which link got the clicks.