LessonsHow to measure visits and useful actions on your website

Mini lesson 24 of 30 · Reach people and offer services

Choose what the event really means

Who is this for?

People who want to understand website visits and useful actions. An assistant can connect the supplied tracking example; you decide what a measurement means and inspect the result.

Measure the result you care about, not a nearby click.

Purpose of this lesson

  • Define an action without confusing a click with completion.
  • Inspect actual collected events.
  • Keep consent, failed collection and private data separate.
Explanation, worked example and practice

Before you start

Your own GA4 practice property/web stream and the supplied separate page. A coding assistant can configure it and guide DebugView. Isolate the practice events and use synthetic activity, not private visitor data.

Check your starting skills

These are useful skills, not locked course requirements. If you can already do them, start this lesson; otherwise open the linked preparation. The supplied starter files mean you do not need an existing personal website.

  1. How to publish your website from GitHub

    Connect a practice repository to hosting.

Estimated time: 19–31 min

Estimates for the supplied starter files with prerequisite accounts and tools ready. Setup, deployment queues and delivery/DNS waits take additional time. The example is a consent-gated practice setup, not a complete jurisdiction-specific consent system. Account reports can lag.

Understand the idea

Open the supplied practice page over HTTP with your assistant. Its “Open workshop instructions” button reveals an instructions section. The useful result is that the instructions became visible, not that someone merely pressed a button.

Use measurement-plan.csv to describe that result as workshop_open, once per page load after analytics is allowed. The exercise counts recorded activity only; it cannot tell you how many blocked or non-consenting visitors used the feature.

A concrete example

Suppose the button was pressed but an error kept the instructions hidden. That is an attempted interaction, not a successful workshop_open. A subscription would likewise count as completed only after its own success condition.

Use the supplied analytics page and my dedicated GA4 test stream. Configure the public measurement ID and keep Enhanced Measurement off for this isolated exercise. Explain workshop_open as the first visible opening after this page load. Test each branch from a fresh reload: Keep analytics off then open; Allow analytics then open twice; and a blocked collector request. Show page_view and workshop_open separately in Network and my own DebugView. Do not send email, free text or private identifiers. The basic buttons choose initial consent for one page load; do not present Keep analytics off as withdrawing consent after Allow.

Files for this step

Start hereWorkshop files

Open or download the files below. When saving a project, keep the folder paths shown in the filenames.

Try it yourself

The supplied button is pressed but the instructions stay hidden. Should this count as workshop_open, and what observable result should count?

Show a worked solution

It should not count. I would count workshop_open when the instructions first become visible after analytics is allowed, at most once in that page load. A second click that leaves the same instructions open should not add another opening.

What a sound answer includes

  • Defines the event as visible instructions rather than a button press.
  • Uses one first opening per page load as the exercise’s counting rule.
How it works (optional)

Measure visits and a useful action

Decide what a number means before adding a tracker.

A page view tells you that a page was recorded, while a meaningful action tells you something about use. Here the action is opening workshop instructions, not merely hovering over a button.

This example loads GA4 only after a practice opt-in. Its numbers therefore describe recorded consenting activity, not a complete census of all visitors. Blocking, consent and network failures can all create measurement gaps.

Worked example

workshop_open is sent only when the instructions become visible for the first time in this tab. It is not labelled sign_up or purchase because neither happened.

Extra implementation exercise

A visitor clicks a subscribe button but verification fails. Should that be counted as a completed subscription?

Show a worked solution

No. You can count an attempt separately, but completed subscription should be triggered only after the system confirms success.

  • Distinguishes attempted interaction from successful outcome.
  • Names the event to match observed behaviour.

Step 1 · How to measure visits and useful actions on your website

Connect only the practice measurement

Let the assistant handle the integration while you limit the data.

Explanation, worked example and practice

Understand the idea

Ask the assistant to connect your dedicated GA4 web stream and disable Enhanced Measurement for this isolated test. The measurement ID is public configuration. Keep personal message text, email addresses and private URL information out of event values.

The page begins with analytics off. “Allow analytics for this test” enables it for that page load; “Keep analytics off” only keeps an initially off page off. It is not an undo button after Allow. Reload before switching test branches. A public site needs a proper consent-preference and withdrawal flow beyond this small exercise.

A concrete example

For the supplied action, workshop_id can be the fixed value practice-one. It does not need the visitor’s email or the text they typed into another form. The reference assignment uses explanation_open instead of workshop_open; compare each version against its own event name.

Files for this step

Start hereWorkshop files

Open or download the files below. When saving a project, keep the folder paths shown in the filenames.

Try it yourself

Which event values does this practice need, which private data will you exclude, and how will you start an analytics-off test?

Show a worked solution

I would send workshop_open with workshop_id practice-one, plus the separate practice page_view after opt-in. I would exclude email addresses, message text and private URL information. For the off branch I would reload first, choose “Keep analytics off” and then open the instructions. Clicking it after Allow would not withdraw consent in this lab.

What a sound answer includes

  • Uses the fixed action identifier without private free text or identity.
  • Starts the off branch with a fresh load and does not treat Decline-after-Allow as consent withdrawal.
How it works (optional)

Configure a small, intentional event set

Use one test stream and inspect exactly what leaves the page.

Create your own GA4 web stream, disable its Enhanced Measurement for this isolated exercise and set config.js to its measurement ID. It is public configuration; do not confuse it with a privileged service key.

The script suppresses the automatic page view and sends one explicitly after opt-in. It removes query/hash from page_location, clears the referrer field and sends only a fixed workshop ID with the action. Keep names, email addresses and form text out of events.

Enhanced Measurement is disabled here only to isolate this lesson's explicit events. On a real site, choose measurement features according to a reviewed plan rather than assuming they should always be off. Keep this practice stream separate and inspect unexpected traffic: a public measurement ID is not an authentication boundary for genuine visitor events.

Worked example

A URL containing ?email=someone@example.com must not become an event parameter. The supplied code uses only origin plus pathname for its own location field; do not put personal data into path segments either.

GA4: set up events · GA4: configuration fields

Extra implementation exercise

Why should the measurement plan list excluded data as well as event names?

Show a worked solution

Event parameters and URLs can leak information unintentionally. Define what must stay out, then inspect the browser request to verify the code follows that boundary.

  • Anticipates accidental personal-data collection.
  • Checks actual outgoing payloads.

Step 2 · How to measure visits and useful actions on your website

Check the provider’s actual event

A local queued event is not yet provider collection.

Explanation, worked example and practice

Understand the idea

Run two separate tests with your assistant. Test A: reload, choose “Keep analytics off”, then open the instructions. They should appear with no Google analytics script or collector request. Test B: reload, choose Allow, then open the instructions twice.

For Test B, the explicit practice counts should be one page_view and one workshop_open. Inspect browser requests and the matching event in your own DebugView separately; queued commands are not receipt. If you open the instructions before Allow, that opening is not counted later, so reload and repeat the prescribed order.

A concrete example

Expected matrix: off → open = 0 page_view, 0 workshop_open; fresh load → Allow → open twice = 1 page_view, 1 workshop_open. These are counts of the named practice events, not a claim that all automatic GA4 event types total two.

Files for this step

Start hereWorkshop files

Open or download the files below. When saving a project, keep the folder paths shown in the filenames.

Try it yourself

Run the fresh-load off test and the fresh-load Allow/open-twice test. What happened locally, and which named events reached your test stream?

Show a worked solution

Illustrative result: after a fresh off choice, the instructions opened and no analytics request was made: 0 page_view and 0 workshop_open. After a new load and Allow, two open clicks produced one page_view and one workshop_open in the test stream. If Network queues these commands but DebugView shows no receipt, provider ingestion remains unverified rather than passed.

What a sound answer includes

  • Uses a separate fresh page load for each consent branch and the specified action order.
  • Compares the expected 0/0 and 1/1 named-event counts with actual browser and provider observations.
How it works (optional)

Verify collection separately from local queuing

An entry in dataLayer does not prove Google received it.

Keep analytics off and verify that opening the instructions still works without loading gtag.js. In a fresh tab allow the test, inspect the outgoing requests and open GA4 DebugView or Realtime.

Click the workshop button twice. This implementation sends its action once per page load. A blocked script may leave a local queue without a received event; a quiet dashboard alone does not prove that nobody visited.

The opened flag is held only in page memory. Reloading starts a new measurement instance and can record another opening; this is not a durable unique-person count. An opening before consent is not retroactively emitted after opt-in.

Worked example

If the browser queues workshop_open but a blocker prevents the collection request, the feature can still work while GA4 misses it. Check the tracking path before inferring a traffic collapse.

Extra implementation exercise

Your local queue contains the event but DebugView does not. What have you verified, and what remains unknown?

Show a worked solution

You verified that the page created an event command. Confirm the right measurement ID, script/request delivery and account view before claiming ingestion.

  • Claims local event creation only.
  • Investigates network/account ingestion separately.

Step 3 · How to measure visits and useful actions on your website

Verify one new meaningful action

Keep the definition, implementation and test together.

Explanation, worked example and practice

Understand the idea

Ask the assistant to implement the supplied explanation-opening variant. Its successful action is an explanation becoming visible, named explanation_open with explanation_id practice-one. The reference keeps the same once-per-load and initial-consent behavior.

Repeat the fresh-load off test and Allow/open-twice test for this new event, then have the assistant simulate a blocked analytics request locally. The explanation should remain usable even when collection fails. Save expected and observed results in analytics-tests.txt.

A concrete example

For the reference version, the target is 0 explanation_open while off and 1 after Allow plus two open clicks. Seeing workshop_open instead would mean the original action is still being measured, even if the button’s visible label changed.

Files for this step

Start hereWorkshop files

Open or download the files below. When saving a project, keep the folder paths shown in the filenames.

Try it yourself

Submit the explanation-opening change with off, on/repeated-click and blocked-collection results. Which event was actually measured?

What to produce: An event definition and actual positive/negative collection observations.

Show a worked solution

Illustrative handoff: the explanation opens without tracking in the off branch; a fresh Allow branch followed by two clicks sends one explanation_open with explanation_id practice-one, plus the separate page_view. Blocking collection leaves the explanation readable but no provider receipt is claimed. This verifies the named action and initial-consent test, not a production withdrawal system.

What a sound answer includes

  • Measures the visible explanation with explanation_open and the corresponding fixed identifier.
  • Checks zero before consent, one after allowed repeated opening and continued feature use when collection fails.
How it works (optional)

Your assignment: measure one real outcome

Choose a feature whose successful result your site can observe.

Write a measurement plan for one feature: a confirmed signup, a successful download request or a completed search. Define attempt and success separately where relevant.

Implement a fixed, nonpersonal event and verify that a failed action does not emit success. Document blockers/consent limits and remove debug mode before a real release.

Worked example

A form button click may produce feedback_attempt; only a successful server response should produce feedback_accepted. Neither proves that a later email was delivered.

The complete reference walkthrough is available in reference/assignment-walkthrough.txt. Compare its steps with your own result; fill the test record from observations in your own project.

Extra implementation exercise

Produce an event definition, implementation and positive/negative collection record.

Show a worked solution

Define an action that the system can actually observe. The reference practice feature opens a local explanation and emits one fixed explanation_open event only after that explanation becomes visible, not simply when a button is pressed.

Before opt-in, perform the task and confirm it works without loading Google's script. After opt-in in a fresh tab, inspect page_view and the action's payload/count in Network and your own DebugView. Click twice and verify the documented once-per-tab rule.

Keep free text, email, query/hash and identifying path content out of events. A local queued command is not remote ingestion; a blocker or wrong stream can leave reports empty even when the page works. Remove debug mode and implement a suitable persistent consent/withdrawal flow before public use.

  • Success matches the system's actual knowledge.
  • No free text/personal identity is sent and failed actions do not emit success.

Was this lesson useful?

Leave a like, or share it with someone who could use it.