Sub topic 14
Documenting events in a tracking plan
A tracking plan is a shared document that lists every event your site sends to GA4. For each event it records the parameters, the trigger, and who owns it. This chapter assumes you can already send events with gtag.js or a GTM data layer push. It also assumes you know the difference between recommended and custom events, and the GA4 naming rules and limits from earlier chapters. Here you will turn those decisions into a document that a team can review, implement, test, and maintain.
Why a plan matters
GA4 accepts almost any event name you send. It does not warn you about a typo, a second spelling of the same event, or a parameter that nobody registered as a custom dimension. Without a plan, three problems show up:
- Duplicate meaning. One developer sends
newsletter_signup_click. Another sendsNewsletterSignupClick. GA4 names are case-sensitive, so these become two unrelated events. - Silent drift. A parameter is renamed in code. Reports that depended on the old name stop filling in, and nobody notices for weeks.
- Quota waste. Each unused event name and each registered custom dimension counts against property limits. Standard properties allow a fixed number of event-scoped custom dimensions (50 at the time of writing). Check the current limits in the GA4 documentation.
A plan makes each of these a review comment instead of a data-quality incident.
What a plan row contains
Give each event one row. These columns cover the decisions made in earlier chapters:
| Column | What it records | Example |
|---|---|---|
| Event name | Exact, case-sensitive name | `newsletter_signup_click` |
| Type | Recommended or custom (automatic and enhanced events are listed for reference only) | custom |
| Trigger | The user action or system condition that fires it | Click on the footer signup button |
| Parameters | Name, type, allowed values, required or optional | `placement` (string: `footer`, `sidebar`), `plan_type` (string: `free`, `pro`) |
| Implementation | gtag.js, GTM data layer, or Measurement Protocol | GTM Custom Event trigger |
| Custom definitions | Which parameters are registered as custom dimensions or metrics | `placement` registered as event-scoped dimension |
| Key event | Whether it is marked as a key event | No |
| Owner | A person or team who approves changes | Growth team |
| Status | Proposed, in review, live, deprecated | Live |
Two columns are worth special attention. The Type column records the decision from the "Deciding which kind of event to use" chapter. A reviewer can then see that you checked the recommended list before inventing a name. The Custom definitions column is the link between your code and your reports. A parameter that is sent but not registered appears in DebugView and in BigQuery exports, but you cannot use it as a dimension in standard reports or explorations.
Writing parameter specifications
Vague parameter notes cause most plan failures. "Page type" tells an implementer nothing. Write each parameter as a small contract:
- Name. Follow the same snake_case rules as event names, within the 40-character name limit.
- Type. String or number. Strings are limited to 100 characters in standard properties, and a longer value is truncated.
- Allowed values. List them, or state the pattern. A closed list such as
footer,sidebar,modalkeeps reports from filling with variants. - Required or optional. Recommended events define their own required parameters. For example,
purchaseneedstransaction_id,value,currency, anditems. Copy those requirements into the plan rather than pointing to the Google docs, so reviewers can check them in one place. - Source. Say where the value comes from, such as a data layer variable, a DOM attribute, or a server response.
Count parameters per event as well. An event can carry up to 25 custom parameters, and the items array of an ecommerce event has its own limits. A plan that lists parameters explicitly lets you see when an event is growing too large.
An example plan fragment
Here is a fragment for three events from this tutorial. You can keep a plan like this in a spreadsheet, a wiki table, or a version-controlled file. The spreadsheet is easiest for non-developers. The file is easiest to check automatically.
| Event name | Type | Trigger | Parameters | Registered as dimension | Key event |
|---|---|---|---|---|---|
| `login` | recommended | Successful sign-in | `method` (string: `Google`, `email`) | No | No |
| `purchase` | recommended | Order confirmation page loads | `transaction_id`, `value`, `currency`, `items` | No | Yes |
| `tutorial_complete` | custom | Learner finishes the last lesson | `tutorial_id` (string, slug) | `tutorial_id` | Yes |
Notice what the plan makes visible. tutorial_complete is the only event that needs a custom dimension. It is also the only row where a parameter needs registration before it can appear in reports. The purchase row has no registered dimension because the standard ecommerce reports already read its parameters.
Keeping the plan checkable
A plan in a document drifts from the code. A plan in a structured file can be checked on every pull request. The script below reads a plan written as a JavaScript array and reports entries that break the naming rules. It runs with Node.js and has no dependencies.
const RESERVED_PREFIXES = ['ga_', 'firebase_', 'google_'];
const NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
const MAX_NAME_LENGTH = 40;
const MAX_PARAMS = 25;
function checkName(kind, name) {
const problems = [];
if (name.length > MAX_NAME_LENGTH) {
problems.push(`${kind} "${name}" is longer than ${MAX_NAME_LENGTH} characters`);
}
if (!NAME_PATTERN.test(name)) {
problems.push(`${kind} "${name}" should be snake_case and start with a letter`);
}
if (RESERVED_PREFIXES.some((prefix) => name.startsWith(prefix))) {
problems.push(`${kind} "${name}" uses a reserved prefix`);
}
return problems;
}
function checkPlan(plan) {
const problems = [];
const seen = new Set();
for (const entry of plan) {
if (seen.has(entry.name)) {
problems.push(`event "${entry.name}" is listed twice`);
}
seen.add(entry.name);
problems.push(...checkName('event', entry.name));
if (entry.params.length > MAX_PARAMS) {
problems.push(`event "${entry.name}" has more than ${MAX_PARAMS} parameters`);
}
for (const param of entry.params) {
problems.push(...checkName('parameter', param));
}
}
return problems;
}
const plan = [
{ name: 'login', params: ['method'] },
{ name: 'tutorial_complete', params: ['tutorial_id'] },
{ name: 'newsletter_signup_click', params: ['placement', 'plan_type'] },
{ name: 'NewsletterSignupClick', params: ['Placement'] },
{ name: 'google_promo_view', params: ['promo_id'] }
];
const problems = checkPlan(plan);
if (problems.length === 0) {
console.log('Plan is valid.');
} else {
problems.forEach((problem) => console.log(problem));
process.exitCode = 1;
}Running it prints one line for each problem in the last two entries and exits with a nonzero code, so a CI job fails. The script checks only what can be decided from names. It cannot tell you whether the event fires on the right trigger. That check belongs to DebugView, covered in the validation chapter.
A change process
A plan has value only if changes go through it. Use a short workflow like this one:
- A person proposes an event or a parameter change by editing the plan.
- A reviewer checks the recommended events list for an existing match, then checks naming, limits, and whether the parameter needs registering.
- The implementer builds the change in gtag.js or in GTM.
- The change is verified in DebugView or Tag Assistant preview against the plan row.
- Custom dimensions are registered and key events are marked.
- The status column changes to live.
Step 5 comes after validation on purpose. Registering a custom dimension is hard to undo: you can archive it, but it keeps counting against your quota. Register a parameter only after you have seen it arrive with correct values in DebugView.
Retiring events
Events are rarely deleted from GA4. Historical data stays, and a name you stop sending simply stops appearing. Handle retirement in the plan instead:
- Set the status to deprecated and record the date and the replacement event.
- Remove the trigger and tag, so the event stops firing.
- Keep the row. A future team member who sees old data under that name can find out what it meant.
- If a key event is deprecated, unmark it so it stops showing up in conversion reports.
Do not reuse a deprecated name for a different meaning. Reports that span the change mix two meanings under one name.
Common mistakes
- Plan written after launch. Retrofitting a plan means reverse-engineering the code and guessing intent. Write the row before the implementation.
- Parameters described only in prose. If allowed values are not listed, nobody can detect a bad value.
- Everything marked as a key event. Key events are for outcomes that matter to the business. A plan column that makes you answer "Key event: yes or no?" for every event discourages over-marking.
- No owner. An event without an owner is never reviewed, never retired, and eventually misunderstood.
- Plan and container out of sync. If you use GTM, store the tag name and trigger name in the plan so a reviewer can find the implementation quickly.
Exercise
Your team wants to track clicks on a "Download brochure" button. A teammate proposes the event name DownloadBrochure with a parameter Brochure ID, and no recommended event fits. Rewrite the proposal as a valid tracking plan row (event name, parameter name, parameter type and allowed values, and whether the parameter needs a custom dimension), and say what a reviewer should check before approving.
Show answer
Event name: download_brochure_click (snakecase, starts with a letter, well under 40 characters). Parameter: `brochureid, a string of up to 100 characters with allowed values such as the brochure slugs. Parameter names cannot contain spaces, and names are case-sensitive, so use lowercase. The parameter needs an event-scoped custom dimension if the team wants to report on it by brochure. Before approving, the reviewer checks that no recommended event already covers the interaction, that the name does not use a reserved prefix such as ga, firebase, or google_`, and that the plan row names an owner and a trigger. After implementation, verify the event and parameter in DebugView, then register the dimension.
Exercise
A developer renames tutorial_complete to tutorial_completed in the code and updates nothing else. What happens in GA4, and what should the plan show?
Show answer
GA4 starts recording a new event named tutorial_completed. The old tutorial_complete data stays under the old name, and reports or key event settings that referenced the old name stop receiving new data. The plan should show tutorial_complete as deprecated with a date and a pointer to tutorial_completed. It should show tutorial_completed as a new row. The new row needs its own custom dimension registration for tutorial_id if the dimension is not already registered, and its own key event marking if it was a key event.