DM5: Tracking: events, tags and measurement plans

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

Testing tracking before you trust it

🎯You'll be able to

Check events with browser tools and automated tests, find doubled, missing and malformed events, and run a tracking QA checklist before release.

🏠The everyday picture

Before a wedding, someone counts the chairs, checks the sound system and walks the route from the gate to the hall. Finding a problem the day before is far better than during the ceremony.

📘What it really is

📝A worked example

Input: Project 1's test 7 reloads the thank-you page twice.

Steps:

  1. On the starter, read the failure: three purchase events for one order.
  2. In shop.js, before sending purchase, check a stored list of sent order IDs; send only if this ID isn't there, then add it.
  3. Run the test again.

Expected output: one purchase per order, however often the page is reloaded.

🌍Where it's used

📝Case scenario

After a redesign, a shoe shop's conversion rate doubled overnight. Nobody had improved anything: the new thank-you page sent purchase twice. Two weeks of campaign decisions had been made on doubled numbers before an analyst compared them with the order database.

🖱️Try it

Run npm run test:tracking on your Project 1 work and read the first failing test's message. Fix just that, and run it again. Success: one more test passes, and you can say what the event looked like before and after.

⚠️Common mistakes

🛠️For your project

Project 1's ten tests are a tracking QA checklist in code; all ten should pass, twice in a row, before you trust MittiMart's data.

✅Quick check

How do you stop a purchase being counted twice when the thank-you page is reloaded?

Show the answer

Remember the transaction_ids already sent, and send purchase only for a new one.

What does a sudden doubling of conversions after a release usually mean?

Show the answer

A tracking problem, such as an event firing twice, until checked against orders.

← PreviousCampaign tags (UTM parameters)
ProLearners Assist