DM5: Tracking: events, tags and measurement plans
Campaign tags (UTM parameters)
🎯You'll be able to
Tag campaign links with UTM parameters, keep names consistent, and carry campaign information through a visit.
🏠The everyday picture
A shop hands out leaflets with a code: "Show this leaflet for 10% off: code PARK-OCT". At the till they count which leaflets brought customers.
📘What it really is
- UTM parameters are added to links you control (emails, social posts, partner sites, QR codes):
utm_source: where the link is (newsletter,instagram,partner-blog);utm_medium: the type of channel (email,social,referral,cpc);utm_campaign: the campaign (diwali-2026);-
optional
utm_content(which link or creative) andutm_term(search keyword). -
Example:
https://www.mittimart.example/?utm_source=newsletter&utm_medium=email&utm_campaign=diwali-2026. - Naming rules: lower case, hyphens, a shared list of allowed values.
Email,emailande-mailbecome three channels in reports. -
Session attribution: the tags arrive on the landing page only. Analytics tools keep them for the visit, so later events (a purchase) are credited to the campaign. MittiMart's solved
tags.jsstores them insessionStorage. -
Don't tag internal links (from one MittiMart page to another): it starts a new "campaign" in the middle of a visit and breaks attribution.
-
Ad platforms often add their own click IDs automatically; UTMs are mostly for channels you manage yourself.
- Keep UTMs free of personal data: don't put an email or phone number in a campaign tag.
📝A worked example
Input: the starter tags.js ignores UTM tags.
Steps:
- On page load, read
utm_source,utm_mediumandutm_campaignfrom the address; if present, store them insessionStorage. - Add them to every
page_viewascampaign_source,campaign_mediumandcampaign_name. - Run
npm run test:trackingand read test 9.
Expected output: both page views in the test visit (the tagged home page, then the shop page) carry newsletter, email and
diwali-2026.
🌍Where it's used
- Email teams tag every link in a newsletter.
- Social teams tag links in posts and profile bios.
- Offline campaigns put tagged links in QR codes on posters and packaging.
📝Case scenario
A cosmetics brand's influencers each made up their own tags: "Insta", "instagram", "IG", "insta_story". The campaign report showed 23 "sources". A shared spreadsheet that generated links from fixed lists solved it for the next campaign.
🖱️Try it
Write tagged links for MittiMart's shop page for three channels: the newsletter, an Instagram bio, and a QR code on packaging. Success:
lower case, consistent medium values (email, social, offline or similar), and one campaign name.
⚠️Common mistakes
- Inconsistent spelling. Sign:
Emailandemailas separate channels. Fix: a fixed list and a link builder. - Tagging internal links. Sign: a visit "restarting" in reports. Fix: tag only links from outside the site.
- Dropping tags after the first page. Sign: purchases credited to "direct". Fix: keep campaign values for the visit.
🛠️For your project
Project 1's test 9 opens a tagged link, then another page, and checks both page views carry the campaign.
✅Quick check
Which three UTM parameters are most used?
Show the answer
utm_source, utm_medium and utm_campaign.
Should links between pages of your own site carry UTM tags?
Show the answer
No; they restart attribution in the middle of a visit.
