DM5: Tracking: events, tags and measurement plans

Lesson 4 of 5 · reading 15–25 minutes; practice and project time is on the module page

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

📝A worked example

Input: the starter tags.js ignores UTM tags.

Steps:

  1. On page load, read utm_source, utm_medium and utm_campaign from the address; if present, store them in sessionStorage.
  2. Add them to every page_view as campaign_source, campaign_medium and campaign_name.
  3. Run npm run test:tracking and 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

📝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

🛠️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.

← PreviousMeasurement plans
ProLearners Assist