Skip to content
Faisal Mahmud TusherDigital marketing, SEO & analytics
with Faisal Tusher

Analytics › Beginner

Specifying Tags and Triggers for a Sign-Up Form

A practice specification for one of the most common tracking jobs: counting newsletter sign-ups through Tag Manager. You choose the trigger that counts real sign-ups rather than attempts, define the variables and the event tag, and write the Preview mode test that proves it fires once per sign-up.
ExerciseBeginner levelModule 2: GA4 and Tag Manager basics5 minUpdated

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.

Illustrative example — not a real result

Quillmark Stationery: the form, the container and the plan

ItemDetail
Form locationsFooter of every page; a pop-up on product pages after 30 seconds
FieldsEmail address and a consent tick box
SubmissionSent by JavaScript to the email platform; the page does not reload
SuccessThe form is replaced by "Thanks, check your inbox"
FailureAn inline error appears; nothing is sent
Container todayGoogle tag on the Initialisation trigger; a constant variable holding the measurement ID; an exception trigger for the office IP range
Tracking plan lineEvent 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.

  1. 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.
  2. Define every variable the tag and trigger need, saying for each whether it is built in or user defined, and what type.
  3. Specify the event tag: type, measurement ID, event name, parameters, firing option and exceptions.
  4. List anything that must not be sent, and why.
  5. Write the Preview mode test plan: the actions, what you expect to see on each, and the checks in DebugView.
  6. 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.

FieldValue
NameGA4 event: newsletter_signup
TypeGA4 event
Measurement IDThe existing constant variable
Event namenewsletter_signup, copied from the tracking plan
Parametersform_location from the data layer variable
Firing triggerCustom event: newsletter_signup
ExceptionThe existing office IP exception trigger
Firing optionOnce per event
ConsentNo 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_signup event in the timeline and no tag fired.
  • Submit a valid test address in the footer. Expect one newsletter_signup event; open the Tags tab and confirm the tag fired once with form_location set to footer.
  • 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.

Illustrative example — not a real result

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. newsletterSignup in 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.

Pages this lesson applies

Terms used on this page

Also related

Related