Why this matters
A sign-up form looks like the easiest thing to track, and it is where many containers first go wrong. A trigger on the button click counts attempts, including the ones that failed validation. A trigger on a generic form submission may never fire on a form that sends without reloading the page. Both produce a number that looks plausible, so nobody questions it.
You have read how tags, triggers and variables compose in the guide to Tag Manager's building blocks, how an event tag is built in the tutorial on installing GA4 through GTM, and how a session in the debugger runs in the debugging and Preview mode tutorial. The GA4 setup tutorial covered the property side. This exercise asks you to make the decisions those pages explain, for one form.
The form and its behaviour
Quillmark Stationery is an invented online shop selling notebooks and pens. Its newsletter form appears in two places, and the developer has described how it behaves.
Quillmark Stationery: the form, the container and the plan
| Item | Detail |
|---|---|
| Form locations | Footer of every page; a pop-up on product pages after 30 seconds |
| Fields | Email address and a consent tick box |
| Submission | Sent by JavaScript to the email platform; the page does not reload |
| Success | The form is replaced by "Thanks, check your inbox" |
| Failure | An inline error appears; nothing is sent |
| Container today | Google tag on the Initialisation trigger; a constant variable holding the measurement ID; an exception trigger for the office IP range |
| Tracking plan line | Event newsletter_signup; parameter form_location with values footer or popup; to be marked as a key event |
The developer offers to add this push, after the email platform confirms the address was accepted:
dataLayer.push({ event: "newsletter_signup", form_location: "footer" })
Writing the specification
A good specification answers four questions without the implementer needing to ask anything: what fires, when, with which values, and how you will know it worked. Name each object the way the container already names things, reference the existing constant rather than retyping the ID, and write the test as a script someone else could follow.
Task
Write your specification before reading the worked answer.
- Choose the trigger. Compare a click trigger on the button, a form submission trigger and a custom event trigger on the developer's push, and justify your choice.
- Define every variable the tag and trigger need, saying for each whether it is built in or user defined, and what type.
- Specify the event tag: type, measurement ID, event name, parameters, firing option and exceptions.
- List anything that must not be sent, and why.
- Write the Preview mode test plan: the actions, what you expect to see on each, and the checks in DebugView.
- Note the tasks that belong in Google Analytics rather than the container.
Worked answer
Trigger. Use a custom event trigger matching newsletter_signup exactly. The click trigger counts
attempts, including failed ones. The form submission trigger listens for the browser's own submit, which a
JavaScript form that never reloads may not produce, and without validation checks it also counts attempts.
The push happens only after the email platform accepts the address, so it is the one signal that means a
real sign-up.
Variables. A data layer variable reading form_location, with a default of unknown so a missing key is
visible rather than blank. The existing constant for the measurement ID. The built-in Event variable,
enabled, for reading in Preview.
Tag.
| Field | Value |
|---|---|
| Name | GA4 event: newsletter_signup |
| Type | GA4 event |
| Measurement ID | The existing constant variable |
| Event name | newsletter_signup, copied from the tracking plan |
| Parameters | form_location from the data layer variable |
| Firing trigger | Custom event: newsletter_signup |
| Exception | The existing office IP exception trigger |
| Firing option | Once per event |
| Consent | No additional consent beyond the built-in checks, matching the other analytics tags |
Must not be sent. The email address, in any parameter. It identifies a person directly, and sending it breaks Google Analytics' terms. The push contains no address, and the specification says so in writing so nobody adds it later.
Preview test plan.
- Load a product page in Preview. Confirm the Google tag fired on Initialisation and nothing fired for the newsletter.
- Submit the footer form with an invalid address. Expect an inline error, no
newsletter_signupevent in the timeline and no tag fired. - Submit a valid test address in the footer. Expect one
newsletter_signupevent; open the Tags tab and confirm the tag fired once withform_locationset tofooter. - Repeat in the pop-up and confirm
popup. - Double-click submit on a valid address. Expect one push and one tag firing; if there are two, the developer's push needs guarding.
- Check the Variables tab on the sign-up event, not the page view, and glance at the Errors tab.
- In DebugView, confirm each event arrived with the right parameter and no duplicate. Then remove the test addresses from the email platform.
Google Analytics tasks. Register form_location as an event-scoped custom dimension so it can be
reported, and mark newsletter_signup as a key event counting once per session, since a resubmission is
still one sign-up.
What the first test run found
The first Preview pass showed 2 newsletter_signup events for 1 pop-up sign-up: the pop-up script pushed
on success and again when the visitor closed it. The footer form behaved correctly, with 1 push per
sign-up and form_location set to footer. The developer removed the second push, a rerun of all 6
checks passed, and the version was published with a note naming the fix and the date of the test.
Common mistakes
- Tracking the button. Clicks are attempts; the business wants sign-ups.
- Retyping the measurement ID. Use the constant the container already holds.
- Event names that differ by a character.
newsletterSignupin the trigger matches nothing the site pushes. - Reading variables on the wrong event. Values on the page view say nothing about the sign-up event.
- Stopping at "tag fired". DebugView is where you confirm the property received it.
- Forgetting the dimension. An unregistered parameter appears in DebugView and nowhere else.
Then check yourself in the GA4 and Tag Manager checkpoint, or return to the beginner analytics level.
