
Mini lesson · English
How to measure visits and useful actions on your website
Measure one useful visitor action in the supplied page, then compare consent-off, consent-on and repeat-click results with an assistant.
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.
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.
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.
What you will learn
- Define an action without confusing a click with completion.
- Inspect actual collected events.
- Keep consent, failed collection and private data separate.
Step 1
Choose what the event really means
Measure the result you care about, not a nearby click.
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
Open or download the files below. When saving a project, keep the folder paths shown in the filenames.
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.
Common mistake
Giving an event a successful-sounding name before the action completes.
Step 2
Connect only the practice measurement
Let the assistant handle the integration while you limit the data.
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.
GA4: set up events · GA4: configuration fields
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?
Discuss your answer with the lesson tutor
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.
- 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.
Files for this step
Open or download the files below. When saving a project, keep the folder paths shown in the filenames.
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.
Common mistake
Sending raw user messages to analytics because they seem useful for debugging.
Step 3
Check the provider’s actual event
A local queued event is not yet provider collection.
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.
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?
Discuss your answer with the lesson tutor
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.
- 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.
Files for this step
Open or download the files below. When saving a project, keep the folder paths shown in the filenames.
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.
Common mistake
Using a successful console log as proof of remote analytics collection.
Step 4
Verify one new meaningful action
Keep the definition, implementation and test together.
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.
Try it yourself
Start with these materials
The starter files and test content are supplied. A live verification still requires your own permitted provider account, inbox or domain as listed under prerequisites. Local inspection is possible without them; record the live step as not tested until you actually perform it.
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.
Discuss your answer with the lesson tutor
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.
- 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.
Files for this step
Open or download the files below. When saving a project, keep the folder paths shown in the filenames.
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.
Common mistake
Explaining every analytics drop as a drop in real human interest.
Was this lesson useful?
Leave a like, or share it with someone who could use it.
Continue learning
- How to build your first personal website
- How to publish your website from GitHub
- How to connect a custom domain to your website
- How to set up email on your own domain
- How to make your website usable on phones
- How to make website images load faster
- How to get website feedback in your inbox
- How to add email subscriptions to your website
- How to send automated emails from your website
- How to save form submissions in a database
- How to let people sign in to your website
- How to keep a page private
- How to let users edit their profile information
- How to let users upload images
- How to keep API keys out of your frontend
- How to show data from an external API on your website
- How to add an AI chatbot to your website
- How to make a chatbot answer from your own content
- How to add a blog to your website
- How to add search to your website
- How to add another language to your website
- How to help Google find your website
- How to fix your website preview when sharing a link
- How to let visitors book an appointment
- How to accept a payment on your website
- How to preview website changes before publishing
- How to undo a broken website deployment
- How to back up and restore your website data
- How to find and fix errors on your live website