How to Create a Tracking Plan for Revenue
On this page
- Stage 1: The tag audit that found every observed order counted twice
- Stage 2: The tracking plan that assigns each event an owner
- Stage 3: The browser purchase sent through the data layer
- Stage 4: The webhook path for renewals and refunds
- Stage 5: The checks that prove each path behaves as planned
- Stage 6: The fixed month reconciled against Stripe
Analytics & Data
GA4 says last month's revenue was $59,570. Stripe says customers paid $39,200. Nobody can explain which number to trust. To create a tracking plan, audit what fires today, write one row per event with its trigger, parameters, owner and destination, implement it, send money events from the payment processor, test, then reconcile against the processor.
Copperleaf Coffee Roasters is fictional, and every Copperleaf number here is hypothetical. It has nine people, a custom storefront, Stripe Checkout, Google Tag Manager, GA4 and a CRM/email platform. It sells roasted beans as one-off orders and monthly subscriptions; wholesale cafes order by phone and receive Stripe invoices.
For the arithmetic, each checkout order is $35.00 gross: $31.00 merchandise, $3.00 shipping and $1.00 tax. Each renewal is $28.00 gross: $25.00 merchandise and $3.00 shipping. Renewal tax is assumed to be zero to keep the example simple.
Google and Stripe documentation was read on 29 October 2026.
Stage 1: The tag audit that found every observed order counted twice
Start with the tags and data that exist, including the code that sits outside your tag manager. Copperleaf compares its Stripe checkout orders with GA4 purchases for September, then inspects the confirmation page, GTM tags and event parameters.
| Hypothetical September check | Copperleaf finding | Consequence |
|---|---|---|
| Stripe checkout orders | 1,120 paid orders at $35 each, or $39,200 gross | The payment record for this comparison |
| GA4 observed orders | 851 of the 1,120 orders, approximately 76% | 269 checkout orders have no observed browser purchase |
| GA4 purchase events | 1,702 events: each of the 851 observed orders fired twice | The hard-coded gtag snippet and the GTM tag both fire on /thank-you |
| GA4 purchase revenue | 1,702 events at $35 each, or $59,570 | GA4 exceeds Stripe gross by $20,370 despite missing 269 orders |
| Purchase parameters | Neither tag sends transaction_id; both send gross as value | There is no usable purchase ID for deduplication, and shipping and tax inflate value |
| Confirmation URL | /thank-you?order=1043&email=jane%40example.com appears in page_location | An email address can reach GA4 in the URL |
| Newsletter tag | newsletter_signup includes an email parameter | A customer identifier is being sent as event data |
| Site search | Customers sometimes type phone numbers into view_search_results | Search input can carry personal information into analytics |
| Subscription renewals | No event is sent | Renewal revenue is invisible in GA4 |
The two errors in the revenue figure pull in opposite directions. The browser misses 269 checkout orders, while duplication and a gross-valued value parameter inflate every order it does observe. A total that happens to look plausible would still hide both faults.
The email address in the example URL is illustrative. Remove email from the confirmation URL and the newsletter_signup event, and prevent phone numbers entered into search from being sent to GA4. Google's PII best practices identify URLs, page titles, form fields and search boxes as places where personal information can reach Analytics.
Google states the rule in its Measurement Protocol, SDK, and User ID Feature Policy. The same policy says violations may result in termination of the Google Analytics account and loss of its data.
You must not upload any data that allows Google to personally identify an individual
Remove the email from the URL at its source. GA4 data redaction is a best-effort safety net for web streams; it does not cover Measurement Protocol, and it does not replace checking what your site sends.
Check the stream's redaction settings as well. Google's data redaction documentation describes email redaction and selected URL query-parameter redaction, along with the limitations. Keep personal information out of event parameters, page URLs and search terms before collection.
Stage 2: The tracking plan that assigns each event an owner
A tracking plan is an operating agreement in a table. It says what causes an event, what goes with it, who owns the implementation and which system receives it. Add a source-of-record column so a marketing report cannot quietly become the authority on money.
Copperleaf's hypothetical tracking plan is an excerpt a small team could copy into a spreadsheet:
| Event | Trigger | Parameters | Owner | Destination | Source of record |
|---|---|---|---|---|---|
purchase (browser) | Confirmed checkout order, once per order ID | transaction_id, merchandise value, tax, shipping, currency, items, customer_type | Developer | GTM to GA4 | Stripe for money |
purchase (server) | Stripe invoice.paid for billing_reason subscription_cycle, with a stored ga_client_id | transaction_id as invoice ID, merchandise value, currency, items | Developer | Webhook to Measurement Protocol to GA4 | Stripe for money |
refund | Stripe reports a refund for an order with a usable web identity | Original purchase transaction_id, refund value, currency | Developer | Webhook to Measurement Protocol to GA4 | Stripe for money |
begin_checkout | Customer starts checkout | value, currency, items | Developer | GTM to GA4 | GA4 for site behavior |
newsletter_signup | Signup is confirmed | form_location; no email address | Marketing | GTM to GA4; customer details go to CRM | CRM for customer record |
| Wholesale phone order | Stripe invoice is paid, with no web identity | None sent to GA4 | Operations | Stripe and CRM | Stripe for money; CRM for customer record |
The browser purchase row uses Copperleaf's own order ID, such as CL-10432. A renewal uses the Stripe invoice ID because each paid renewal invoice represents a separate transaction. A refund must carry the ID used for the original purchase, so the webhook implementation needs a reliable mapping from the refunded payment to that ID.
The measurement plan guide sets out event naming rules, limits, reserved names, key events and DebugView mechanics. The analytics guide for a small business explains the source-of-truth split: use the payment processor for money, the CRM for customers and GA4 for site behavior.
Each row needs a trigger precise enough for another person to test. “When someone buys” leaves room for a checkout click, an unpaid session and a page reload to be treated as the same thing. “Confirmed checkout order, once per order ID” gives the developer and the tester a shared observable condition.
Record changes alongside the plan. If marketing renames form_location or the developer changes the confirmation page, the row should show who changed it and when. Otherwise, the spreadsheet becomes a historical document with an optimistic title.
Stage 3: The browser purchase sent through the data layer
The site must emit a purchase only when it has a confirmed order, with values from that order. For Copperleaf's hypothetical checkout, the data is:
| Hypothetical field | Value | Check |
|---|---|---|
transaction_id | CL-10432 | Copperleaf's unique order ID |
items | Two House Blend bags at $15.50 each | price times quantity equals $31.00 |
value | $31.00 | Merchandise only |
shipping | $3.00 | Sent separately |
tax | $1.00 | Sent separately |
| Gross paid | $35.00 | $31.00 plus $3.00 plus $1.00 |
The following push uses Google's ecommerce structure for GTM. It clears the previous ecommerce object first, so values left by an earlier ecommerce event do not carry into the purchase. Google's ecommerce measurement instructions show the clear and push pattern, and calculate value from item prices and quantities.
window.dataLayer = window.dataLayer || [];
dataLayer.push({ ecommerce: null });
dataLayer.push({
event: "purchase",
ecommerce: {
transaction_id: "CL-10432",
value: 31.00,
tax: 1.00,
shipping: 3.00,
currency: "USD",
customer_type: "new",
items: [
{ item_id: "HB-340", item_name: "House Blend 340g", price: 15.50, quantity: 2 }
]
}
});
Configure one GA4 Event tag in GTM with event name purchase, ecommerce data from the data layer, and a Custom Event trigger named purchase. Remove the hard-coded purchase snippet. The site should prevent the push from repeating for the same order when the confirmation page reloads; the unique ID provides a further safeguard.
Google says GA4 deduplicates purchase events with the same transaction ID on web streams. That behavior does not apply to app streams. Reusing an ID across different orders causes undercounting, and an empty transaction_id causes purchases with empty IDs to be deduplicated together. Google does not state a deduplication time window in its transaction ID guidance.
The later renewal path also needs the real GA4 client_id associated with the checkout. Read it in the browser using the Google tag's get method, pass it to the server creating the Checkout Session, and store it as subscription metadata under ga_client_id. Store Copperleaf's order_id as metadata too, so the payment and order can be joined; do not put email addresses or card data in metadata.
That handoff belongs in the storefront implementation, where the order and Checkout Session are created. Iron Goo's website foundation build includes instrumenting analytics for a site. Whoever builds the handoff should document what happens when there is no available client_id: the payment still proceeds, while that server event has no web identity to send to GA4.
Stage 4: The webhook path for renewals and refunds
A browser tag reports events the browser sees. Server-side tagging runs a tag container on a server that receives and processes data before sending it to destinations. It changes where tags run; it does not automatically give that server knowledge of a completed payment.
| Hypothetical Copperleaf event | Incoming evidence | GA4 path | Decision |
|---|---|---|---|
| Initial checkout purchase | Confirmed order on the browser's return | Data layer to GTM to GA4 | Send once with Copperleaf's order ID |
| Monthly renewal | Stripe invoice.paid, with billing_reason subscription_cycle | Webhook to Measurement Protocol | Send with the stored ga_client_id and invoice ID |
| Refund | Stripe refund linked to an earlier purchase | Webhook to Measurement Protocol | Send refund with the original purchase ID |
| Wholesale phone invoice | Stripe paid invoice, with no web identity | No GA4 event | Keep the order in Stripe and the CRM |
| Purchase never reported by browser | Stripe payment exists, browser confirmation event absent | No browser purchase in GA4 | Count the gap during reconciliation |

The browser path reports what the storefront sees. The Stripe webhook path supplies renewal and refund events that do not require a customer to return to the site.
In my opinion, a server-side GTM container is not Copperleaf's first fix. A server container cannot recover a browser purchase that was never sent to it. Google's Cloud Run setup guide recommends at least two instances and estimates approximately $45 per server per month at the documented configuration, or about $90 a month for two by our arithmetic. Copperleaf can revisit that cost if control over third-party tags or page speed becomes the problem to solve.
Stripe is the payment source of record. Its Checkout fulfillment documentation says a landing page alone is unreliable because customers are not guaranteed to reach it. Listen for checkout.session.completed for fulfillment, and handle the appropriate later payment event for delayed payment methods. That payment workflow is separate from the browser purchase event in this example.
For webhooks, verify the Stripe-Signature header with the endpoint's whsec_ secret, return a 2xx response quickly, and log processed event IDs. Stripe can deliver an event more than once, does not guarantee event order, and retries live-mode deliveries with exponential backoff for up to three days. Those behaviors are documented in Stripe's webhook guide.
The following Node handler is a starting point to test in Stripe test mode. It handles renewal purchases only: a production implementation also needs the refund path, durable event processing and a way to recover failed sends. The in-memory Set disappears on restart and does not coordinate multiple processes.
const express = require("express");
const Stripe = require("stripe");
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
const app = express();
const processed = new Set(); // use a database table in production
app.post("/stripe/webhook", express.raw({ type: "application/json" }), async (req, res) => {
let event;
try {
event = stripe.webhooks.constructEvent(
req.body,
req.headers["stripe-signature"],
process.env.STRIPE_WEBHOOK_SECRET
);
} catch (err) {
return res.status(400).send(`Webhook Error: ${err.message}`);
}
res.sendStatus(200); // acknowledge first, then do the slow work
if (processed.has(event.id)) return;
processed.add(event.id);
if (event.type === "invoice.paid") {
const invoice = event.data.object;
const meta = invoice.parent?.subscription_details?.metadata || {};
if (invoice.billing_reason !== "subscription_cycle" || !meta.ga_client_id) return;
const shippingPriceId = process.env.SHIPPING_PRICE_ID;
const items = invoice.lines.data
.filter((line) => line.pricing?.price_details?.price !== shippingPriceId)
.map((line) => {
const qty = line.quantity ?? 1;
return {
item_id: line.pricing?.price_details?.product,
item_name: line.description,
price: line.amount / 100 / qty,
quantity: qty,
};
});
await sendPurchase(meta.ga_client_id, invoice, items);
}
});
async function sendPurchase(clientId, invoice, items) {
const value = items.reduce((sum, item) => sum + item.price * item.quantity, 0);
const body = {
client_id: clientId,
events: [{
name: "purchase",
params: {
transaction_id: invoice.id,
value: Number(value.toFixed(2)),
currency: invoice.currency.toUpperCase(),
items,
},
}],
};
const url = "https://www.google-analytics.com/mp/collect" +
`?measurement_id=${process.env.GA_MEASUREMENT_ID}&api_secret=${process.env.GA_API_SECRET}`;
try {
const response = await fetch(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
if (!response.ok) console.error("Measurement Protocol send failed", response.status);
} catch (err) {
console.error("Measurement Protocol send failed", err.message);
}
}
app.listen(4242);
Subscription-type invoice lines inherit the subscription metadata, so line metadata cannot tell shipping from coffee. The example identifies shipping by its Price ID and reads the product from each line's pricing details. Test it against real test-mode invoices before use. The code reads the subscription metadata snapshot from parent.subscription_details.metadata; Stripe's metadata documentation describes that snapshot and warns against storing sensitive payment details in metadata.
A production receiver should durably record the verified event and arrange its processing before acknowledging it. The sample acknowledges first for clarity, so a process failure after the 200 can lose work. It also marks an event processed before the Measurement Protocol send succeeds, which means a failed send needs an explicit recovery mechanism.
For a refund, look up the original GA4 purchase ID and the stored web identity, then send a refund event with the relevant transaction_id, value and currency. Keep the Stripe refund as the financial record even if no usable web identity exists. Wholesale phone orders remain in Stripe and the CRM: inventing a client_id would invent a user.
Measurement Protocol sends JSON to https://www.google-analytics.com/mp/collect with measurement_id and api_secret in the query string. Google describes it as a supplement to tagging and says events sent only through Measurement Protocol may have partial reporting. For new server-to-server integrations, Google recommends the Data Manager API; Measurement Protocol remains operational with no planned deprecation. See the Measurement Protocol overview.
Stage 5: The checks that prove each path behaves as planned
Run the checks with Stripe test-mode payments and a test renewal. Give each test order a distinct ID, retain its expected merchandise value and compare it with the events actually received. A successful payment alone does not prove that GA4 received the intended event.
| Hypothetical test | Expected observable result | Evidence to retain |
|---|---|---|
Checkout order CL-10432 | One purchase, transaction_id CL-10432, value 31.00, currency USD, two items | Tag Assistant and DebugView observations |
| Confirmation-page reload | No additional purchase push; no extra purchase in the later GA4 report | Reload observation and report check |
| Renewal invoice | One server purchase, invoice ID as transaction_id, merchandise-only value | Stripe test event and Measurement Protocol validation response |
| Refund | refund carries the original purchase transaction_id and the expected amount | Stripe test refund and validation response |
| Webhook delivery | Stripe Dashboard shows a 200 response for the test delivery | Delivery record |
| Personal-information check | No email in the confirmation URL or newsletter_signup; no phone number sent from site search | URL, event parameters and search test |
Use this checklist as the release gate:
- Tag Assistant shows one
purchasefor each test order, with the expectedtransaction_id,value,currencyanditems. - DebugView shows the same purchase once for each test order.
- Reloading the confirmation page produces no additional purchase push, and the later GA4 report has no extra purchase for that order.
- A renewal request sent to
https://www.google-analytics.com/debug/mp/collectreturns an emptyvalidationMessagesarray. - A refund test returns an empty
validationMessagesarray and uses the original purchase ID. - Stripe Dashboard shows
200deliveries for the test webhook events. - A search of
page_locationforemail=and%40finds no email-bearing confirmation URL. - A test newsletter signup sends
form_locationwithout anemailparameter. - A test search containing a phone number does not send that number to GA4.
- The web stream's data redaction settings are enabled and match the intended query-parameter checks.
The Measurement Protocol validation server checks the request format; events sent to it do not appear in reports. The production collection endpoint will not tell you that an event was malformed, so a successful HTTP response there is not a substitute for validation.
After release, assign someone to review changes to event names and parameters. The data hygiene guide sets out a practical way to catch naming drift and maintain a change log. A tracking plan is useful only while it describes what the site sends.
Stage 6: The fixed month reconciled against Stripe
Copperleaf's October figures use the same order assumptions as September. The duplicate browser tag is gone, merchandise is separated from shipping and tax, and the hypothetical renewal path has delivered all 420 renewal events. The browser still observes only part of checkout activity.
| Hypothetical October reconciliation | Calculation | Amount |
|---|---|---|
| Stripe checkout gross | 1,180 orders × $35.00 | $41,300 |
| Stripe renewal gross | 420 renewals × $28.00 | $11,760 |
| Stripe gross | Checkout plus renewals | $53,060 |
| Less shipping | Checkout $3,540 plus renewals $1,260 | $4,800 |
| Less tax | Checkout $1,180; renewal tax assumed zero | $1,180 |
| Stripe merchandise | $53,060 less $4,800 and $1,180 | $47,080 |
| GA4 browser purchase revenue | 897 observed checkout orders × $31.00 | $27,807 |
| GA4 renewal purchase revenue | 420 renewals × $25.00 | $10,500 |
| GA4 purchase revenue | Browser purchases plus renewals | $38,307 |
| Unobserved checkout merchandise | 283 checkout orders × $31.00 | $8,773 |
| Refunds | 30 orders, reconciled separately | $1,050 |
The checkout merchandise total is $36,580, and renewal merchandise is $10,500. Together they make the $47,080 comparable merchandise base. The 283 unobserved checkout orders are the difference between Stripe's 1,180 paid checkout orders and GA4's 897 browser purchases.
$53,060 Stripe gross - $4,800 shipping - $1,180 tax - $8,773 unobserved checkout merchandise = $38,307 GA4 purchase revenue

Follow the deductions from Stripe gross to the GA4 purchase revenue figure. Shipping and tax explain part of the difference; checkout orders the browser did not report explain the rest.
The refund row is separate from the purchase revenue calculation. Copperleaf checks the 30 refunded orders and $1,050 against Stripe and its refund events; it does not subtract that figure from the GA4 purchase revenue shown in the table. Wholesale phone invoices also stay outside this checkout-and-renewal comparison.
The browser observed 897 of 1,180 checkout orders, or 76.0%. September's 851 of 1,120 was approximately 76% as well. A customer declining consent, a blocker or a closed tab before confirmation are possible reasons an individual browser event is absent; the hypothetical totals do not establish which cause accounts for each missing order.
The guide to reading data without fooling yourself explains how differing definitions and dates can make two tools answer different questions. Copperleaf's house rule is to use GA4 for rates and paths, Stripe for money, and investigate when the observed checkout share moves by more than five percentage points month on month. Apply the same rule by running the audit table against your own last 30 days.
Put your next steps in order
Build on what you have just read with a free ebook on semantic SEO and AI visibility. Get worked examples, decision rules, checklists and a do-this-week action in every chapter, plus a six-week plan for your site.



