DATALYR

Stripe Google Analytics: get Stripe revenue into GA4

Send Stripe purchases to Google Analytics 4 from a success page or with the Measurement Protocol, avoid double counts, and know what GA4 will still miss.

By DATALYR · · 4 min read

Contents

How Stripe payments reach GA4

Stripe payments reach Google Analytics 4 in one of two ways: a purchase event fired by your GA tag on the page customers return to after paying, or a server-side event sent with the GA4 Measurement Protocol when Stripe tells your server the checkout completed. Stripe's own GA4 guide describes both.

The success-page route is quick and ties the purchase to the browser session GA4 already knows. The server route records purchases even when the redirect fails, but it needs the visitor's GA client ID to join the purchase to the visit.

Either way, GA4 sees the purchase moment only. Renewals, refunds and disputes happen later in Stripe, without a page view.

Option one: the success page

Add your GA tag to the product, success and cancel pages, and fire begin_checkout just before redirecting the browser to Stripe Checkout. On the success page, send a purchase event with a value, a currency and a transaction ID.

Add checkout.stripe.com to GA4's list of unwanted referrals. Otherwise the return from Stripe can start a new session credited to Stripe as a referral, and the purchase loses the campaign that brought the visitor. In GA4 this lives under the web stream's tag settings.

Use the Checkout Session ID as the transaction ID by including {CHECKOUT_SESSION_ID} in the success URL. GA4 uses the transaction ID to help avoid duplicate purchases when a customer reloads the page.

Option two: send it from the server

When Stripe sends checkout.session.completed to your webhook, your server can post a purchase event to GA4 with the Measurement Protocol. Google states that the protocol is meant to augment automatic collection, not replace it, so the GA tag still runs on your site.

The event joins the visitor's session only if it carries the same client ID. Stripe's guide shows the pattern: read the GA client ID in the browser, store it in the Checkout Session metadata when you create the session, and send it back with the Measurement Protocol event. To attach the event to a specific session's device and location data, Google asks for the session ID and for the event to arrive within 24 hours of the session start.

Without the stored client ID, the purchase lands on an anonymous visitor and GA4 cannot connect it to the campaign.

Example: three counts of one month

This is a hypothetical month. Stripe records 100 paid Checkout Sessions. Ninety-four buyers reach the success page; six close the tab during the redirect. Ten of the 94 reload the success page once.

Without a transaction ID, the success-page tag sends 94 + 10 = 104 purchase events. With the session ID as the transaction ID, GA4 can collapse the reloads toward 94. Stripe's count is 94 + 6 = 100.

The same month also has 400 renewal invoices at $49, or 400 × $49 = $19,600, which reach no page at all. A GA4 revenue report built on the success page will show none of it unless you send renewals from the server too.

Where the counts come from

Success-page tag

104 events, ~94 after dedup

Reloads add events; closed tabs subtract purchases.

Stripe

100 paid sessions + $19,600 renewals

The payment record, including revenue with no page view.

Hypothetical month. Renewal figure: 400 invoices × $49.

Attribute Stripe revenue to campaigns

GA4 is built for behavior analysis across your site and app. If the question is which campaign produced paying customers and their renewals, the payment record needs to be the source of revenue and the visit needs to be the source of the campaign.

DATALYR connects to Stripe with OAuth and receives payments, subscriptions, refunds and disputes from Stripe directly. It links each payment to the web visit through the visitor ID the Web SDK passes to Stripe Checkout and Payment Links, and falls back to email matching. A renewal is credited to the campaign that acquired the customer, and refunds are subtracted.

Many teams run both: GA4 for on-site behavior, DATALYR for revenue by campaign and for sending paid conversions to ad platforms.

Verify with one test payment

Open your pricing page in a private window with a test UTM such as utm_source=doctest, then complete one Stripe test payment through your production code path. In GA4 DebugView, confirm one purchase with the session ID as its transaction ID and the doctest source on the session.

In DATALYR, the same test appears in Events as checkout.session.completed with its value and currency, on a visitor ID that does not start with stripe_. A stripe_ prefix means the visitor ID never reached Stripe.

Related articles.

See what really drives revenue.

Real-time attribution, analytics and conversions for every channel, campaign and ad, ready for your team and your agents.

Get started