Iron Goo
A coffee roaster and robot study two unequal bars on a wall monitor in a warm roastery office.

How to Create a Tracking Plan for Revenue

Atamyrat Hangeldiyev
Atamyrat Hangeldiyev
Systems Architect
February 25, 2026
On this page
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 checkCopperleaf findingConsequence
Stripe checkout orders1,120 paid orders at $35 each, or $39,200 grossThe payment record for this comparison
GA4 observed orders851 of the 1,120 orders, approximately 76%269 checkout orders have no observed browser purchase
GA4 purchase events1,702 events: each of the 851 observed orders fired twiceThe hard-coded gtag snippet and the GTM tag both fire on /thank-you
GA4 purchase revenue1,702 events at $35 each, or $59,570GA4 exceeds Stripe gross by $20,370 despite missing 269 orders
Purchase parametersNeither tag sends transaction_id; both send gross as valueThere 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_locationAn email address can reach GA4 in the URL
Newsletter tagnewsletter_signup includes an email parameterA customer identifier is being sent as event data
Site searchCustomers sometimes type phone numbers into view_search_resultsSearch input can carry personal information into analytics
Subscription renewalsNo event is sentRenewal 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

Google Analytics, Measurement Protocol, SDK, and User ID Feature Policy
An email address in a URL can reach analytics

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:

EventTriggerParametersOwnerDestinationSource of record
purchase (browser)Confirmed checkout order, once per order IDtransaction_id, merchandise value, tax, shipping, currency, items, customer_typeDeveloperGTM to GA4Stripe for money
purchase (server)Stripe invoice.paid for billing_reason subscription_cycle, with a stored ga_client_idtransaction_id as invoice ID, merchandise value, currency, itemsDeveloperWebhook to Measurement Protocol to GA4Stripe for money
refundStripe reports a refund for an order with a usable web identityOriginal purchase transaction_id, refund value, currencyDeveloperWebhook to Measurement Protocol to GA4Stripe for money
begin_checkoutCustomer starts checkoutvalue, currency, itemsDeveloperGTM to GA4GA4 for site behavior
newsletter_signupSignup is confirmedform_location; no email addressMarketingGTM to GA4; customer details go to CRMCRM for customer record
Wholesale phone orderStripe invoice is paid, with no web identityNone sent to GA4OperationsStripe and CRMStripe 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 fieldValueCheck
transaction_idCL-10432Copperleaf's unique order ID
itemsTwo House Blend bags at $15.50 eachprice times quantity equals $31.00
value$31.00Merchandise only
shipping$3.00Sent separately
tax$1.00Sent 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 eventIncoming evidenceGA4 pathDecision
Initial checkout purchaseConfirmed order on the browser's returnData layer to GTM to GA4Send once with Copperleaf's order ID
Monthly renewalStripe invoice.paid, with billing_reason subscription_cycleWebhook to Measurement ProtocolSend with the stored ga_client_id and invoice ID
RefundStripe refund linked to an earlier purchaseWebhook to Measurement ProtocolSend refund with the original purchase ID
Wholesale phone invoiceStripe paid invoice, with no web identityNo GA4 eventKeep the order in Stripe and the CRM
Purchase never reported by browserStripe payment exists, browser confirmation event absentNo browser purchase in GA4Count the gap during reconciliation
Browser purchase events and Stripe renewal and refund webhooks follow separate paths into GA4

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.

25 events
Maximum events per Measurement Protocol request
72 hours
Maximum Measurement Protocol backdating
3 days
Stripe live-mode webhook retry period

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 testExpected observable resultEvidence to retain
Checkout order CL-10432One purchase, transaction_id CL-10432, value 31.00, currency USD, two itemsTag Assistant and DebugView observations
Confirmation-page reloadNo additional purchase push; no extra purchase in the later GA4 reportReload observation and report check
Renewal invoiceOne server purchase, invoice ID as transaction_id, merchandise-only valueStripe test event and Measurement Protocol validation response
Refundrefund carries the original purchase transaction_id and the expected amountStripe test refund and validation response
Webhook deliveryStripe Dashboard shows a 200 response for the test deliveryDelivery record
Personal-information checkNo email in the confirmation URL or newsletter_signup; no phone number sent from site searchURL, event parameters and search test

Use this checklist as the release gate:

  • Tag Assistant shows one purchase for each test order, with the expected transaction_id, value, currency and items.
  • 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/collect returns an empty validationMessages array.
  • A refund test returns an empty validationMessages array and uses the original purchase ID.
  • Stripe Dashboard shows 200 deliveries for the test webhook events.
  • A search of page_location for email= and %40 finds no email-bearing confirmation URL.
  • A test newsletter signup sends form_location without an email parameter.
  • 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 reconciliationCalculationAmount
Stripe checkout gross1,180 orders × $35.00$41,300
Stripe renewal gross420 renewals × $28.00$11,760
Stripe grossCheckout plus renewals$53,060
Less shippingCheckout $3,540 plus renewals $1,260$4,800
Less taxCheckout $1,180; renewal tax assumed zero$1,180
Stripe merchandise$53,060 less $4,800 and $1,180$47,080
GA4 browser purchase revenue897 observed checkout orders × $31.00$27,807
GA4 renewal purchase revenue420 renewals × $25.00$10,500
GA4 purchase revenueBrowser purchases plus renewals$38,307
Unobserved checkout merchandise283 checkout orders × $31.00$8,773
Refunds30 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.

October merchandise reconciliation

$53,060 Stripe gross - $4,800 shipping - $1,180 tax - $8,773 unobserved checkout merchandise = $38,307 GA4 purchase revenue

Revenue steps down from Stripe gross through shipping, tax and unobserved orders to 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.

Free ebook

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.

By signing up and confirming your address, you consent to receive the free ebook plus one email every two weeks with 3 or 4 new Iron Goo videos, guides and articles, and nothing else; unsubscribe any time with one click.

Related in Analytics & Data

Ready to move?

Tell us where your business is today. A written assessment lands in your inbox within two business days.

Talk to us