An eCommerce tracking plan: what your shop should measure, and how to write it down

TL;DR

Difficulty: Beginner

A tracking plan is a short table that says which events your shop sends, when, with which details, who owns each one, which consent it needs and where it goes.

  • Start from the weekly questions and the decisions they change, and track only what serves them.
  • Use Google's thirteen recommended eCommerce events with their own names, fill the items array every time, and use the SKU as the one product identifier.
  • Write naming rules once, budget the ten item scoped custom dimensions, and keep personal data out by rule and by test.
  • Let consent decide what fires, push events from the server confirmed state, and test the data layer automatically before every release.

Most shops install a tag first and ask questions later, and end up with hundreds of events nobody can explain. This chapter works the other way round: from the questions an owner asks every week to a tracking plan that names every event, its trigger, its parameters, its owner, its consent and its destination. All of it is worked through on one invented homeware shop in Leeds, with Rails code and a browser test at the end.

Questions first, events second

Most shops start tracking the wrong way round. Someone installs a tag, ticks every box the plugin offers, and a year later the reports hold hundreds of events that nobody can explain. Revenue in one report does not match revenue in another, half the events have no product attached, and the one question the owner actually has still has no answer.

This chapter answers a simpler question: what exactly should my shop measure, and how do I write it down? The answer is a tracking plan. It is a short document that lists every event the shop sends, when it fires, what it carries, who owns it, which consent it needs and where it goes. Everything else in this series (the purchase event, server events, product analytics, reconciliation and attribution) builds on it.

A tracking plan starts with questions, not with events. An event is only worth sending if it helps answer a question that leads to a decision. So before any code, write down the five to ten questions the business asks every week, and the decision each answer would change. Then work out which events, and which details on those events, you need to answer them.

A few terms first, so nobody is left behind. An event is one thing a visitor did, recorded with a name, such as "viewed a product". A parameter is a detail attached to the event, such as which product and at what price. Google Analytics 4 (GA4) is Google's current analytics product, and the event names in this chapter come from its documentation. A tag is a small piece of code that sends events to a tool such as GA4 or Meta.

Example: the questions Priya asks every week

Wrenfield Home is the invented homeware shop I use throughout this series. It sells ceramics, kitchen textiles, lamps and small furniture from Leeds at wrenfieldhome.example, about 1,400 products. Priya owns it, Callum is her developer. The example's baseline: 110,000 sessions a month, a conversion rate of 1.8%, an average order value of £72, a 52% gross margin on product, £14,000 a month on Google and Meta ads and a newsletter of 38,000 subscribers.

Priya writes down her weekly questions and the decision behind each one:

QuestionDecision it changesWhat must be measured
Which homepage and category lists get products clicked?Which lists to keep, reorder or dropEach list shown, each product clicked in it, its position
Which products get viewed a lot and bought rarely?Fix the page, the price or the photos, or delistProduct views and add to basket per product
Where in checkout do people give up?Which checkout step to fix firstEach checkout step reached
Do the spring banners earn their place?Keep, change or remove a bannerBanner shown, banner clicked
What does each channel bring in revenue?Where the next pound of ad spend goesPurchases with order value and the campaign

Five questions, five decisions. Every event in Wrenfield's plan will trace back to at least one of these rows. If Callum later proposes an event that serves none of them, it does not go in. That single rule keeps a tracking plan small enough to test, and a plan that is tested is one Priya can believe.

An event, its parameters and the items array

Every event in an online shop has the same shape: a name, a few parameters about the event itself, and a list of the products involved. Google calls that list the items array. An array is simply a list, and each entry in it is one product with its own details.

Google's reference for the recommended events says that every item needs at least an item_id or an item_name, and that everything else is optional: price, quantity, discount, index, item_brand, item_category to item_category5, item_variant, item_list_id, item_list_name, location_id and affiliation among them. If quantity is not set, it counts as 1.1

At the event level, two parameters matter most for money. value is the monetary value of the event, and Google says it should be the sum of price times quantity for all items, without shipping or tax. currency is the three letter ISO 4217 code, such as GBP, and Google says it is required whenever you set a value, or revenue metrics will not be computed accurately.1

The reason to fill the items array properly, every time, is that product reports in GA4 are built from it. An add_to_cart event without items tells you somebody added something. With items, it tells you which lamp, in which colour, at which price, from which list.

Example: one product view at Wrenfield

A visitor opens the page for the Ash table lamp in oat linen. It costs £64.00 on the page. Wrenfield shows prices including VAT, because it sells to consumers, and the UK standard rate of VAT is 20%.2

Google's reference asks for value without tax.1 So Callum sends prices without VAT, and writes that decision into the plan. Chapter two of this series, the purchase event done right, works through the VAT and shipping decision in full. Here it is enough to convert one price. The net price is the gross price divided by one plus the VAT rate (see Foundations: percentages if that step is new):

pnet=pgross1+rp_{\text{net}} = \frac{p_{\text{gross}}}{1 + r}

where pnetp_{\text{net}} is the price without VAT, pgrossp_{\text{gross}} is the price the customer sees, and rr is the VAT rate written as a decimal, so r=0.20r = 0.20 for 20%.

Worked through for the lamp:

pnet=64.001.20=53.33p_{\text{net}} = \frac{64.00}{1.20} = 53.33

So pnet=53.33p_{\text{net}} = 53.33, and the event Wrenfield sends when the page loads carries one item:

{
  "event": "view_item",
  "ecommerce": {
    "currency": "GBP",
    "value": 53.33,
    "items": [
      {
        "item_id": "WH-LAMP-ASH-OAT",
        "item_name": "Ash table lamp",
        "item_brand": "Wrenfield",
        "item_category": "Lighting",
        "item_category2": "Table lamps",
        "item_variant": "Oat linen",
        "price": 53.33,
        "quantity": 1
      }
    ]
  }
}

The item_id is the SKU (stock keeping unit, the shop's own product code). Using the SKU rather than a database number matters, because the same SKU appears in the product feed for Google Shopping, in the Meta catalogue and in the order records. One identifier, everywhere, is what lets you join the data later.

The thirteen events Google recommends for a shop

Google publishes a list of recommended eCommerce events with fixed names and fixed parameters. Use them. They are the names GA4's built in reports understand, and a shop that invents its own (productView, basket_add) gets empty eCommerce reports in return.1

EventWhen it firesRequired by GoogleUseful extras
view_item_listA list of products is shown: category page, search results, homepage row, related productsitemsitem_list_id, item_list_name, index per item
select_itemA product in a list is clickeditemsthe same list details
view_itemA product page is shownitems, and currency with valuevariant, category
add_to_cartA product is added to the basketitems, and currency with valuequantity
remove_from_cartA product is removed from the basketitems, and currency with valuequantity
view_cartThe basket page is shownitems, and currency with value
begin_checkoutThe first checkout step is shownitems, and currency with valuecoupon
add_shipping_infoThe visitor chooses a delivery methoditems, and currency with valueshipping_tier, coupon
add_payment_infoThe visitor chooses a payment methoditems, and currency with valuepayment_type, coupon
purchaseThe order is completetransaction_id, items, and currency with valuetax, shipping, coupon, customer_type
refundMoney goes back to the customertransaction_id, and currency with valueitems for item refunds
view_promotionAn internal banner or promotion is shownitemspromotion_id, promotion_name, creative_name, creative_slot
select_promotionAn internal promotion is clickednone strictly, but leave out items and some reports drop itthe same promotion details

"Required" here means what Google's reference marks as required. Where currency and value are listed together, the rule is the one above: if you send a value, the currency must come with it.1

Two words in that table need care in British English. GA4 says "cart" and the shop says "basket". The event names stay exactly as Google writes them, because they are identifiers, not prose. The labels your customers see stay British.

Example: one visit at Wrenfield, event by event

A visitor arrives from a Google Shopping ad on a Tuesday evening. Here is what they do and what the plan says should fire:

Tap or click to open full screen and move around

Counted up, a complete visit fires nine eCommerce events: view_item_list, select_item, view_item, add_to_cart, view_cart, begin_checkout, add_shipping_info, add_payment_info and purchase, on top of the page_view events GA4 records by itself. The visitor who leaves after the product page fires three. Each answers a different row of Priya's question table: the list events answer the first, the product and basket events the second, the checkout steps the third, and the purchase the fifth.

Lists and promotions: the events most shops forget

Most shops send view_item and purchase and stop there. The list and promotion events are the ones that answer merchandising questions, and they are the ones most often missing.

view_item_list fires when a list of products is shown, and select_item when one of them is clicked. Both carry item_list_id and item_list_name, and Google says the item level values win over the event level ones when both are set.1 Each item can also carry index, its position in the list. With those three details you can compare lists with each other and positions within a list.

view_promotion and select_promotion do the same for internal banners: the spring sale tile on the homepage, the free delivery strip, the "new in" panel. They carry promotion_id, promotion_name, creative_name and creative_slot.1

The number these events unlock is the list click through rate: how often a list that was shown led to a product being clicked. The formula is a plain ratio (see Foundations: ratios and rates):

CTRℓ=SℓVℓ\text{CTR}_{\ell} = \frac{S_{\ell}}{V_{\ell}}

where CTRℓ\text{CTR}_{\ell} is the click through rate of list ℓ\ell, SℓS_{\ell} is the number of select_item events from that list, and VℓV_{\ell} is the number of view_item_list events for that list in the same period.

Example: two lists on the Wrenfield homepage

In one invented month, the "Bestsellers" row on the homepage is shown 38,000 times and gets 2,660 clicks. The "Recently viewed" row is shown 21,000 times and gets 1,890 clicks. The "You may also like" row on product pages is shown 52,000 times and gets 1,560 clicks.

Worked through, one list at a time:

CTRbestsellers=2,66038,000=0.070\text{CTR}_{\text{bestsellers}} = \frac{2{,}660}{38{,}000} = 0.070

That gives CTRbestsellers=0.070\text{CTR}_{\text{bestsellers}} = 0.070. For the Recently viewed row:

CTRrecent=1,89021,000=0.090\text{CTR}_{\text{recent}} = \frac{1{,}890}{21{,}000} = 0.090

That gives CTRrecent=0.090\text{CTR}_{\text{recent}} = 0.090. And for the related products row:

CTRrelated=1,56052,000=0.030\text{CTR}_{\text{related}} = \frac{1{,}560}{52{,}000} = 0.030

That gives CTRrelated=0.030\text{CTR}_{\text{related}} = 0.030.

So 7.0% of Bestsellers impressions, 9.0% of Recently viewed impressions and 3.0% of related product impressions lead to a click. The related products row is shown most and clicked least. That is a merchandising decision Priya can now make, and she could not make it without item_list_id on both events. Product and category analytics, chapter four of this series, takes these numbers much further.

One caution. Count an impression only when the list was actually seen, not when it was built off screen at the bottom of a long page. Callum fires view_item_list when at least half of the row has scrolled into view, and writes that trigger into the plan. Whatever rule you choose, write it down, or two developers will count it two ways.

The checkout steps show where people give up

Between the basket and the order there are usually three or four screens. Each one loses some people. The checkout events, begin_checkout, add_shipping_info and add_payment_info, mark the moments a visitor gets past each one.1 Without them, the checkout is a black box: people go in and fewer come out.

Two extra parameters make these events far more useful. shipping_tier on add_shipping_info records the delivery option chosen, such as "standard" or "next day". payment_type on add_payment_info records card, PayPal or another method.1 Both turn a step count into an answer: are people leaving because of the delivery price, or because their preferred way to pay is missing?

The number to compute is the step conversion rate: the share of visitors who reached one step that also reached the next.

ck=nk+1nkc_{k} = \frac{n_{k+1}}{n_{k}}

where ckc_{k} is the conversion rate from step kk to the next step, nkn_{k} is the number of sessions that reached step kk, and nk+1n_{k+1} is the number that reached the step after it. It is the same ratio as before, so the Foundations: ratios and rates section covers it.

Example: Wrenfield's checkout in one month

Wrenfield has 110,000 sessions a month and converts 1.8% of them, so it takes 110,000×0.018=1,980110{,}000 \times 0.018 = 1{,}980 orders. The plan's events show where the other sessions stopped. The step counts below are invented for the example, chosen to fit that baseline:

Bar chart of sessions reaching each step in one invented month at Wrenfield Home. 110,000 sessions, 55,000 viewed a product, 9,900 added to the basket, 4,950 began checkout, 3,600 chose delivery, 2,700 chose a payment method and 1,980 purchased, which is the 1.8% conversion rate of the example. Tap or click to open full screen and move around

The step conversion rates, worked through one by one:

FromToCalculationStep rate
SessionsViewed a product55,000 / 110,00050.0%
Viewed a productAdded to basket9,900 / 55,00018.0%
Added to basketBegan checkout4,950 / 9,90050.0%
Began checkoutChose delivery3,600 / 4,95072.7%
Chose deliveryChose payment2,700 / 3,60075.0%
Chose paymentPurchased1,980 / 2,70073.3%

Multiply the six step rates together and you get back the conversion rate: 0.500×0.180×0.500×0.727×0.750×0.733=0.0180.500 \times 0.180 \times 0.500 \times 0.727 \times 0.750 \times 0.733 = 0.018. That check is worth doing on your own numbers, because if it does not come back to the conversion rate in your shop database, an event is missing or firing twice.

Within checkout, the delivery step loses 27.3% of the people who reach it. Because add_shipping_info carries shipping_tier, Callum can see that almost nobody picks next day delivery at £7.95, and Priya can test the price. The eCommerce funnel stage by stage shows how to read and fix each of these drops.

Purchase and refund: the two events that carry the money

The purchase event is the one everything else is judged against. Google lists transaction_id, items, currency and value for it, with tax, shipping, coupon and customer_type as optional extras.1 The transaction_id is the order number, and it is what lets every later system recognise the same order.

The refund event sends money back the other way. It needs the same transaction_id, and Google recommends adding the refunded items if you want refunds per product.1 A shop that never sends refunds will always show more revenue in analytics than in its bank account.

Both events carry so many traps (duplicate purchases on reloaded thank you pages, payment redirects that never come back, VAT in or out, partial refunds) that the next chapter is devoted to them. For the tracking plan, the decisions to record now are the ones below.

Example: Wrenfield's purchase row in the plan

A customer buys the Ash table lamp (£64.00 including VAT) and two linen tea towels at £12.00 each including VAT. Delivery is £4.95. Callum's plan says: value is the net product total, VAT goes in tax, delivery goes in shipping.

Step by step:

  • Gross product total: 64.00+2×12.00=88.0064.00 + 2 \times 12.00 = 88.00.
  • Net product total: 88.00/1.20=73.3388.00 / 1.20 = 73.33. This is value.
  • VAT on the products: 88.00−73.33=14.6788.00 - 73.33 = 14.67. This is tax.
  • Delivery: shipping is 4.95, sent as charged.

The customer pays 88.00+4.95=92.9588.00 + 4.95 = 92.95. The event says value 73.33, tax 14.67 and shipping 4.95, and those three add up to the same 92.95. Nothing is lost, it is only sorted into the fields Google defines. Chapter two covers what happens to the VAT on delivery and how to fire the event from the order itself rather than the browser.

Naming conventions: write them once, then never argue again

When you need an event Google does not define, you name it yourself. Without a rule, three developers will produce newsletterSignup, Newsletter Sign Up and sign_up_newsletter for the same thing, and GA4 will count them as three different events.

Google sets the hard limits. Event names may contain letters, numbers and underscores, no spaces, and must start with a letter. They are case sensitive, so my_event and My_Event are two events. Some names are reserved, such as page_view, session_start, scroll and click, and parameter names may not start with _, firebase_, ga_, google_ or gtag..3 An event name can be at most 40 characters long, and so can a parameter name.4

On top of those limits, I keep five house rules in every plan:

  • Google's name first. If a recommended event exists, use it, even when the wording feels American.
  • All lower case with underscores (written as snake_case), never camel case, never spaces.
  • Object, then action, in the order Google uses for its own: newsletter_signup, size_guide_open, stock_alert_request.
  • No values in names. Never add_to_cart_lamp or promo_spring_click. The lamp and the spring promotion belong in parameters.
  • Units in the plan, not in the value. Money is a number with a separate currency, a weight is in grams, a lead time is in days, and the plan says so.

Example: tidying Wrenfield's old events

Before the plan, Wrenfield's old tag set sent these custom events:

AddToBasket
add-to-basket
newsletter
NewsletterSignup_footer
sizeguide_click_lamps
promo_spring_banner_click

Callum maps them, one by one:

Old nameProblemNew name and parameters
AddToBasket and add-to-baskettwo names for one action, Google has a recommended oneadd_to_cart with items
newsletter and NewsletterSignup_footervague, and the placement baked into the namenewsletter_signup with form_location: "footer"
sizeguide_click_lampsa category inside the namesize_guide_open with the item in items
promo_spring_banner_clicka promotion inside the nameselect_promotion with promotion_id: "spring_2027"

Six names become four, three of them Google's own. Every report that groups by event name now groups correctly, and the plan has one row per event instead of one row per accident.

Custom parameters and their limits

Google's recommended parameters will not cover everything a homeware shop cares about. Material, colour family, whether an item is made to order, the delivery lead time: all of these are useful, and all are custom parameters you add yourself.

The limits are real, and they are lower than people expect. GA4 accepts up to 25 parameters per event, parameter values of up to 100 characters, and up to 27 custom parameters inside the items array of an eCommerce event.4 To see a custom parameter in reports, you register it as a custom dimension. A standard GA4 property allows 50 event scoped custom dimensions, 25 user scoped ones, 10 item scoped ones and 50 custom metrics, and reporting on a new dimension starts 24 to 48 hours after you create it.5 Data sent before you register it does not appear in standard reports afterwards, so register first and send second.

The ten item scoped dimensions are the scarce ones. Spend them on the product details that drive decisions.

Example: Wrenfield's item dimension budget

Priya wants to know whether made to order furniture converts worse than stock items, whether ceramics in neutral colours outsell bright ones, and whether long delivery times scare buyers off. Callum proposes five item scoped custom parameters:

ParameterExample valueQuestion it serves
material"stoneware"Which materials sell
colour_family"neutral"Neutral against bright
made_to_order"yes"Made to order against stock
lead_time_days"14"Long delivery times
stock_status"in_stock"Do low stock badges help

Five of ten item scoped dimensions used, five held in reserve. Each item now carries the 8 standard details from the lamp example plus 5 custom ones, 13 in all, well under the 27 custom item parameters allowed. At event level, the busiest event, purchase, uses transaction_id, value, currency, tax, shipping, coupon, customer_type and items, 8 of the 25 parameters an event may carry. The plan records all of this, so the next person who wants a new dimension can see at a glance what is left.

The tracking plan document

Now the plan itself. It is a table, kept where the whole business can read it and where changes leave a history: a spreadsheet with version history works, a Markdown file in the shop's code repository works better, because the plan then changes in the same review as the code that implements it.

Each row is one event. The columns that matter:

  • Event: the exact name, as sent.
  • Trigger: the precise moment it fires, written so that two developers would implement it the same way.
  • Parameters: every parameter, with its type and an example value.
  • Owner: the one person who answers for the event being right. Not a team, a name.
  • Consent category: which consent it needs before it may fire (more below).
  • Destination: where it goes: GA4, Google Ads, Meta, the shop's own database.
  • Question: which of the business questions it serves. This is the column that stops a plan from growing back into a tangle.

Example: Wrenfield's tracking plan, version 1.0

EventTriggerKey parametersOwnerConsentDestinationQuestion
view_item_listHalf of a product list is in view, once per list per page viewitem_list_id, item_list_name, items with indexCallumAnalyticsGA4Lists
select_itemA product in a list is clickedthe list details, one item with indexCallumAnalyticsGA4Lists
view_itemA product page has renderedcurrency, value, one itemCallumAnalytics, MarketingGA4, MetaProducts
add_to_cartThe server has saved the line itemcurrency, value, the item with quantityCallumAnalytics, MarketingGA4, MetaProducts
remove_from_cartThe server has removed or reduced the line itemcurrency, value, the itemCallumAnalyticsGA4Products
view_cartThe basket page has renderedcurrency, value, all itemsCallumAnalyticsGA4Checkout
begin_checkoutThe first checkout screen has renderedcurrency, value, coupon, all itemsCallumAnalytics, MarketingGA4, MetaCheckout
add_shipping_infoA delivery method is saved on the ordershipping_tier, currency, value, all itemsCallumAnalyticsGA4Checkout
add_payment_infoA payment method is chosenpayment_type, currency, value, all itemsCallumAnalytics, MarketingGA4, MetaCheckout
purchaseThe order is complete in the shoptransaction_id, value, tax, shipping, currency, coupon, customer_type, all itemsPriyaAnalytics, MarketingGA4, Google Ads, Meta, shop databaseRevenue
refundA refund is recorded in the shoptransaction_id, value, currency, refunded itemsPriyaAnalyticsGA4, shop databaseRevenue
view_promotionHalf of a banner is in viewpromotion_id, promotion_name, creative_slotCallumAnalyticsGA4Banners
select_promotionA banner is clickedthe promotion details, featured itemsCallumAnalyticsGA4Banners
newsletter_signupThe signup is confirmed by the serverform_locationPriyaAnalyticsGA4Newsletter

Fourteen rows, every one tied to a question. Notice two choices in the trigger column. add_to_cart fires when the server has saved the line item, not when the button is pressed, so a button press that fails on stock never counts. And purchase belongs to Priya, not Callum, because it is the event the money is judged by, and the owner of the money should own its definition.

The plan also records the rules that hold for every row: prices without VAT, currency always GBP, item_id always the SKU, names in snake_case, version number and date at the top. When a row changes, the version goes up and the change log at the bottom says what changed and why.

What never goes into an event: personal data

The fastest way to turn a tracking plan into a legal problem is to let personal data into an event. Google's policy for Analytics is blunt: no data may be passed to Google that Google could use or recognise as personally identifiable information. It names email addresses, personal mobile numbers, and other details, and says the list is not exhaustive.6

The leaks are rarely deliberate. Google lists where they happen: URLs and page titles, data typed into search boxes and form fields, campaign parameters such as utm_term, and every custom dimension.6 A newsletter form that redirects to /thanks?email=priya@example.com sends the email address to GA4 in the page location. A visitor who types an order number and an email address into the site search sends both as a search term.

GA4 offers data redaction for web streams, which removes email addresses on a best effort basis and strips query parameters you name.6 Use it, but treat it as a safety net. The real fix is in the plan: a rule that no parameter ever carries a name, an email address, a phone number, a street address or a free text field, and a test that checks it.

Example: two leaks Callum closes

The first leak: Wrenfield's old newsletter form redirected to /newsletter/thanks?email=.... Callum changes the redirect to /newsletter/thanks and keeps the address in the server session only. He also switches on data redaction for the query parameters email and phone in GA4 as a second line of defence.

The second leak: site search terms. Out of 1,000 search terms in one invented week, 6 contain an @ sign, because customers paste their email address into the search box when looking for their order. Callum adds one rule to the code that builds the search event, before anything is sent:

// Drop anything that looks like an email address or a long number
function safeSearchTerm(term) {
  if (/@/.test(term)) return '(redacted)'
  if (/\d{7,}/.test(term)) return '(redacted)'
  return term.trim().toLowerCase().slice(0, 100)
}

Six terms a week now arrive as "(redacted)", and the other 994 still answer the question they were collected for: what people look for and fail to find. The 100 character cut matches GA4's limit for parameter values.4 Site search that sells covers what to do with those terms.

The user ID deserves one more line. If you send GA4 a user ID for logged in customers, it must be an internal, meaningless number, never an email address or a customer reference printed on invoices. Hashing an email address does not make it anonymous, a point chapter three of this series goes into.

Every row of the plan carries a consent category, because the law in all four of my markets decides what may run before a visitor agrees. This is general information about how the rules apply to a tracking plan, not legal advice. The detail of each country lives in two earlier articles, cookies, consent and tracking in the UK, Germany and Austria and event tracking and consent mode, so here is only what the plan needs.

In the UK, regulation 6 of the Privacy and Electronic Communications Regulations 2003 (PECR) forbids storing or accessing information on a visitor's device without consent, and Schedule A1 sets out the exceptions.78 One is for what is strictly necessary for the service the visitor asked for. Since February 2026 there is also a statistical purposes exception: no consent is needed if the sole purpose is to collect statistics on how the site is used in order to improve it, the information is shared with nobody except those helping to make the improvements, the visitor gets clear information, and the visitor has a simple, free way to object.8 It does not cover information the device emits automatically.8 Analytics that feeds an advertising company does not fit those conditions easily, and advertising tags never do.

For comparison, the rules in my other markets: Ireland applies Regulation 5 of S.I. No. 336 of 2011,9 Germany § 25 of the TDDDG,10 and Austria § 165 of the TKG 2021.11 None of the three has a statistical exception like the UK's. In all four, analytics and marketing tags wait for consent, and the basket, the login and the record of the consent choice itself may run without it.

In the plan, that becomes three categories:

CategoryWhat it coversMay run before consent?
NecessaryBasket, login, security, the consent recordYes
AnalyticsGA4 and any other measurement toolNo (UK: only a tool that fits the statistical exception)
MarketingGoogle Ads, Meta and any advertising destinationNo

Google's consent mode carries those categories to its tags. A gtag('consent', 'default', ...) command sets ad_storage, ad_user_data, ad_personalization and analytics_storage to denied, and Google says it must run on every page before any command that sends measurement data. After the visitor's choice, a gtag('consent', 'update', ...) command grants what they agreed to.12

// Runs first on every page, before the Google tag loads
window.dataLayer = window.dataLayer || []
function gtag() { dataLayer.push(arguments) }
gtag('consent', 'default', {
  ad_storage: 'denied',
  ad_user_data: 'denied',
  ad_personalization: 'denied',
  analytics_storage: 'denied',
  wait_for_update: 500
})

The wait_for_update value tells the Google tag how many milliseconds to wait for the banner's answer before it acts on the defaults.12

Here is how one event in the plan reaches a decision:

Tap or click to open full screen and move around

Run Wrenfield's fourteen rows through it. None of them is strictly necessary in the legal sense: the basket itself is, but an analytics event about the basket is not. So all fourteen wait for consent. view_item, add_to_cart, begin_checkout, add_payment_info and purchase go to Meta and Google Ads as well, so they need the marketing category on top of analytics. A visitor who accepts analytics and declines marketing still counts in GA4, and is invisible to Meta.

This is why the shop's own database matters so much. The order exists whether or not anybody clicked "accept", and chapter three, the shop database as the source of truth, shows how to use it without breaking the rules above.

One plan, several destinations

GA4 is rarely the only destination. Most shops also send events to Meta for its ads, and Meta has its own names. Its standard events include ViewContent, Search, AddToCart, AddToWishlist, InitiateCheckout, AddPaymentInfo and Purchase, and its Purchase event requires currency and value.13 Instead of an items array, Meta uses content_ids (product IDs such as SKUs), contents (a list with an id and a quantity per product), content_type and num_items.13

The plan should not grow a second set of rows for Meta. Keep one row per event, and add a mapping table: GA4 name, Meta name, and how each parameter translates. One source, two outputs, so the two can never drift apart.

Example: Wrenfield's mapping from GA4 to Meta

GA4 eventMeta eventParameter translation
view_itemViewContentitem_id becomes content_ids, content_type: "product", same value and currency
add_to_cartAddToCartitems become contents with id and quantity
begin_checkoutInitiateCheckoutcontents, plus num_items as the sum of quantities
add_payment_infoAddPaymentInfocontents, value, currency
purchasePurchasecontents, value, currency (both required by Meta)

Take the basket from the purchase example: one lamp and two tea towels. For InitiateCheckout, Meta's num_items is 1+2=31 + 2 = 3. The contents list is two entries, {"id": "WH-LAMP-ASH-OAT", "quantity": 1} and {"id": "WH-TOWEL-LIN-SAGE", "quantity": 2}, and value is the same 73.33 that GA4 receives. Because the same SKUs appear in Wrenfield's Meta catalogue, the ads platform can match each event to a product. Meta and TikTok ads for online shops explains why those matches matter for catalogue ads.

From the plan to code: data layer pushes from a Rails view

A plan only matters once it is in the code. The usual bridge between a shop and its tags is the data layer: a JavaScript object that Google Tag Manager and the Google tag read to pass information to tags.14 The shop pushes events into it, and the tags, once consent allows, read from it. A push to the data layer sends nothing anywhere on its own. It is a list in the visitor's browser that the tags read.

Google's Tag Manager guide shows every eCommerce push in two steps: first dataLayer.push({ ecommerce: null }) to clear the previous eCommerce object, then the new event.15 Without the first step, details of the last product can leak into the next event.

Wrenfield runs on Ruby on Rails and Solidus, the open source eCommerce framework, and that is how I build shops as well. The examples below follow Solidus's own code: current_pricing_options is a helper Solidus makes available to controllers and views,16 a product's master variant can return its price for those options with price_for_options, and order.contents.add(variant, quantity) returns the saved line item.17

First, a helper that builds one GA4 item from a variant and writes the push:

# app/helpers/analytics_helper.rb
module AnalyticsHelper
  UK_VAT = BigDecimal("0.20") # one rate for this example, chapter two covers mixed rates

  def ga4_item(variant, quantity: 1, list_id: nil, index: nil)
    price = variant.price_for_options(current_pricing_options)
    return nil unless price

    {
      item_id: variant.sku,
      item_name: variant.name,
      item_variant: variant.options_text.presence,
      item_category: variant.product.taxons.first&.name,
      price: (price.amount / (1 + UK_VAT)).round(2).to_f,
      quantity: quantity,
      item_list_id: list_id,
      index: index
    }.compact
  end

  def data_layer_push(event, ecommerce)
    payload = { event: event, ecommerce: ecommerce }.to_json
    javascript_tag(nonce: true) do
      <<~JS.html_safe
        window.dataLayer = window.dataLayer || [];
        window.dataLayer.push({ ecommerce: null });
        window.dataLayer.push(#{json_escape(payload)});
      JS
    end
  end
end

In plain words: ga4_item looks up the price the visitor sees, takes the VAT out, and returns a hash with the fields from the plan. compact drops the fields that are empty, so the event never carries a null. data_layer_push writes a small script tag. json_escape makes sure a product name with odd characters can never break out of the script, and nonce: true lets the script run under a strict content security policy.

The product page then pushes view_item as it renders:

<%# app/views/products/show.html.erb %>
<% item = ga4_item(@product.master) %>
<% if item %>
  <%= data_layer_push("view_item",
        currency: current_pricing_options.currency,
        value: item[:price],
        items: [item]) %>
<% end %>

For add_to_cart, the plan says the event fires only when the server has saved the line item. So the cart controller records the fact in the flash (the one request store Rails keeps for the next page), and the layout pushes the event on the page that follows:

# app/controllers/cart_items_controller.rb (the add action)
def create
  variant = Spree::Variant.find(params[:variant_id])
  quantity = params.fetch(:quantity, 1).to_i
  line_item = current_order(create_order_if_necessary: true).contents.add(variant, quantity)

  if line_item.persisted?
    flash[:ga4_add_to_cart] = { "variant_id" => variant.id, "quantity" => quantity }
  end
  redirect_to cart_path
end
<%# app/views/layouts/application.html.erb, inside <body> %>
<% if (added = flash[:ga4_add_to_cart]) %>
  <% item = ga4_item(Spree::Variant.find(added["variant_id"]), quantity: added["quantity"]) %>
  <%= data_layer_push("add_to_cart",
        currency: current_pricing_options.currency,
        value: (item[:price] * item[:quantity]).round(2),
        items: [item]) if item %>
<% end %>

Example: what the browser receives for two tea towels

A visitor adds two linen tea towels in sage to the basket. The towel costs £12.00 including VAT. The server saves the line item, the flash holds the variant and the quantity 2, and the basket page renders with this in its source:

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({ ecommerce: null });
window.dataLayer.push({"event":"add_to_cart","ecommerce":{"currency":"GBP","value":20.0,"items":[{"item_id":"WH-TOWEL-LIN-SAGE","item_name":"Linen tea towel","item_variant":"Sage","item_category":"Kitchen textiles","price":10.0,"quantity":2}]}});

The numbers, step by step: the net price is 12.00/1.20=10.0012.00 / 1.20 = 10.00, the quantity is 2, so value is 10.00×2=20.0010.00 \times 2 = 20.00. JSON writes those as 10.0 and 20.0, which GA4 reads as the same numbers. If the towel had been out of stock, contents.add would not have saved the line item, the flash would be empty, and no event would fire. That is exactly what the plan's trigger column asked for.

Testing the plan: DebugView and an automated test

A tracking plan that is not tested drifts. A template changes, a field gets renamed, a new developer moves the script, and three months later a report quietly shows nothing. Two kinds of test catch that.

The first is by hand, with GA4's DebugView. You switch on debug mode, either through Tag Assistant or Tag Manager's preview mode, or by adding debug_mode: true to the Google tag, and DebugView shows the events from your own device as they arrive, with every parameter.18 Google adds two warnings worth knowing. Events do not show in debug mode if the visitor has not consented to analytics, so accept the banner on your test device first. And to switch debug mode off, you remove the parameter: setting it to false does not switch it off.18

The second is automated, and it is the one that keeps the plan true over time. A browser test opens a page the way a customer would and checks what landed in the data layer. Playwright, an open source browser testing tool, can run JavaScript inside the page and wait until a condition is true.1920 Because the test reads the data layer rather than the network, it works whether or not the tags are allowed to send.

// spec/e2e/tracking_plan.spec.js
import { test, expect } from '@playwright/test'

const findEvent = (name) => (window.dataLayer || []).find((e) => e.event === name)

test('product page pushes view_item as the plan says', async ({ page }) => {
  await page.goto('/products/ash-table-lamp')
  const handle = await page.waitForFunction(findEvent, 'view_item')
  const push = await handle.jsonValue()

  expect(push.ecommerce.currency).toBe('GBP')
  expect(push.ecommerce.value).toBeCloseTo(53.33, 2)
  expect(push.ecommerce.items[0]).toMatchObject({ item_id: 'WH-LAMP-ASH-OAT', quantity: 1 })
})

test('no event carries an email address', async ({ page }) => {
  await page.goto('/products/ash-table-lamp')
  const pushes = await page.evaluate(() => JSON.stringify(window.dataLayer || []))
  expect(pushes).not.toMatch(/[\w.+]+@[\w]+\.[\w.]+/)
})

waitForFunction keeps running findEvent in the page until it returns something, then hands the result back to the test, and jsonValue turns it into a plain object.20 The second test is the personal data rule from the plan, written as a check that fails loudly.

Example: the test that caught a missing currency

Callum refactors the product page template in March and moves the price lookup into a partial. The page looks identical. The Playwright run before the release fails with one line: expected undefined to be "GBP". The new partial built the item but forgot the event level currency.

Without the test, the change would have gone live. GA4 would have received view_item events with a value and no currency, and Google says revenue metrics are then not computed accurately.1 Priya's product report would have shown views with no value for weeks before anyone noticed. With the test, the fix takes one line and five minutes. I work this way on every shop I build: test first, and no release goes out unless it has passed the test gate and been written into the release register.

Keeping the plan alive

A tracking plan is never finished. New products need new parameters, a new payment method needs a new payment_type value, a new banner slot needs a creative_slot. The plan survives those changes if it has three habits.

One owner per row. The owner column is not decoration. When a number in a report looks wrong, the owner is the person who finds out why.

Versions and a change log. Every change gets a new version number, a date and one line on why. When a report shows a jump on a certain day, the change log is the first place to look, and very often the jump is a tracking change, not a change in customer behaviour. Is your dashboard lying to you? lists the other usual suspects.

Change the plan and the code together. The plan lives next to the code, a change to an event is reviewed with the change to the plan, and the automated test is updated in the same step. If the plan says one thing and the code another, the test fails.

Example: adding gift wrapping in version 1.1

In April, Priya adds gift wrapping at £3.50. She wants to know how many orders take it and whether it changes the order value. Callum writes the change:

  • purchase gains a custom parameter gift_wrap with values "yes" or "no".
  • It is registered as an event scoped custom dimension: 1 of the 50 allowed, now 1 in use.5
  • The gift wrap fee goes into neither value nor shipping: the plan says value is products only, so the fee is recorded in the shop database and as its own parameter gift_wrap_fee: 2.92, the net of £3.50 at 20% VAT (3.50/1.20=2.923.50 / 1.20 = 2.92).
  • The Playwright test gains one assertion that a test order with gift wrap pushes gift_wrap: "yes".
  • The change log reads: "1.1, 6 April 2027: gift wrap on purchase, owner Priya, question: does gift wrap raise order value."

Five lines of plan, one parameter, one test. A month later Priya's question has an answer, and anyone who joins the shop in a year can read why the parameter exists.

Conclusion

A tracking plan is a short document with a long life. Start from the questions the business asks and the decisions they change, and track only what serves them. Use Google's thirteen recommended eCommerce events with their own names and parameters, fill the items array every time, and use the SKU as the one identifier that joins every system. Add list and promotion events, because they answer the merchandising questions most shops cannot. Write naming rules once, budget the scarce custom dimensions, and keep every row with a trigger, parameters, an owner, a consent category, a destination and a question. Keep personal data out by rule and by test. Let consent decide what fires, and let the shop's own database hold what consent hides. Then test the plan automatically, so it stays true after every release. The next chapter takes the one event that carries the money, the purchase, and gets it exactly right.

If your shop's events grew without a plan and nobody trusts the reports any more, book the free workshop: we write your tracking plan together from your own questions, and the first two weeks of work are on me.

Sources

  1. 1.

    Google, Recommended events reference (eCommerce events, item parameters, value and currency notes), Google for Developers, Google Analytics, checked 22 November 2026, https://developers.google.com/analytics/devguides/collection/ga4/reference/events

  2. 2.

    HM Revenue and Customs, VAT rates, GOV.UK, checked 22 November 2026, https://www.gov.uk/vat-rates

  3. 3.

    Google, Event naming rules, Analytics Help, checked 22 November 2026, https://support.google.com/analytics/answer/13316687

  4. 4.

    Google, [GA4] Event collection limits, Analytics Help, checked 22 November 2026, https://support.google.com/analytics/answer/9267744

  5. 5.

    Google, [GA4] About custom dimensions and metrics, Analytics Help, checked 22 November 2026, https://support.google.com/analytics/answer/10075209

  6. 6.

    Google, Best practices to avoid sending Personally Identifiable Information (PII), Analytics Help, checked 22 November 2026, https://support.google.com/analytics/answer/6366371

  7. 7.

    The Privacy and Electronic Communications (EC Directive) Regulations 2003, regulation 6, as substituted on 5 February 2026 by the Data (Use and Access) Act 2025, legislation.gov.uk, https://www.legislation.gov.uk/uksi/2003/2426/regulation/6

  8. 8.

    The Privacy and Electronic Communications (EC Directive) Regulations 2003, Schedule A1, exceptions to regulation 6, paragraphs 4 and 5, inserted 5 February 2026, legislation.gov.uk, https://www.legislation.gov.uk/uksi/2003/2426/schedule/A1

  9. 9.

    European Communities (Electronic Communications Networks and Services) (Privacy and Electronic Communications) Regulations 2011, S.I. No. 336 of 2011, Regulation 5, Irish Statute Book, 2011, https://www.irishstatutebook.ie/eli/2011/si/336/made/en/print

  10. 10.

    Telekommunikation Digitale Dienste Datenschutz Gesetz (TDDDG), § 25 Schutz der Privatsphäre bei Endeinrichtungen, Bundesministerium der Justiz, gesetze im internet, https://www.gesetze-im-internet.de/ttdsg/__25.html

  11. 11.

    Telekommunikationsgesetz 2021 (TKG 2021), § 165 Datenschutz, Allgemeines, Linde Verlag law database (the official RIS database did not respond when checked on 22 November 2026), https://linda.lindeverlag.at/Dokument/537514_165/

  12. 12.

    Google, Set up consent mode on websites, Google for Developers, Tag Platform, checked 22 November 2026, https://developers.google.com/tag-platform/security/guides/consent

  13. 13.

    Meta, Meta Pixel reference: standard events and object properties, Meta for Developers, checked 22 November 2026, https://developers.facebook.com/docs/meta-pixel/reference

  14. 14.

    Google, The data layer, Google for Developers, Tag Platform, checked 22 November 2026, https://developers.google.com/tag-platform/tag-manager/datalayer

  15. 15.

    Google, Measure ecommerce, Tag Manager implementation, Google for Developers, Google Analytics, checked 22 November 2026, https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtm

  16. 16.

    Solidus, core/app/helpers/spree/core/controller_helpers/pricing.rb (current_pricing_options), solidusio/solidus on GitHub, main branch, checked 22 November 2026, https://github.com/solidusio/solidus/blob/main/core/app/helpers/spree/core/controller_helpers/pricing.rb

  17. 17.

    Solidus, core/app/models/spree/simple_order_contents.rb (add returns the line item), solidusio/solidus on GitHub, main branch, checked 22 November 2026, https://github.com/solidusio/solidus/blob/main/core/app/models/spree/simple_order_contents.rb

  18. 18.

    Google, Monitor events in DebugView, Analytics Help, checked 22 November 2026, https://support.google.com/analytics/answer/7201382

  19. 19.

    Playwright, Evaluating JavaScript, Playwright documentation, checked 22 November 2026, https://playwright.dev/docs/evaluating

  20. 20.

    Playwright, Page class reference, page.waitForFunction, Playwright documentation, checked 22 November 2026, https://playwright.dev/docs/api/class-page#page-wait-for-function