How to Track Gravity Forms Stripe Subscriptions in GA4 via GTM

When a Gravity Forms payment form uses Stripe with no AJAX, the browser performs a standard full-page redirect to a thank you page after submission. This makes tracking straightforward: pass the transaction value in the URL, read it with GTM, and fire a GA4 purchase event on arrival.

What you need before starting:

  • Gravity Forms with a Stripe payment field (no AJAX)
  • A thank you page the form redirects to after payment
  • Google Tag Manager installed on your site
  • A GA4 property with a Google Tag already firing in GTM

Part 1 — Pass the Transaction Value via URL in Gravity Forms

Gravity Forms has a built-in option to append form field values to the confirmation page URL as query parameters. You will use this to carry the total transaction value into the thank you page, where GTM can read it.

  1. Go to WordPress Admin → Forms → your form → Settings → Confirmations
  2. Open your existing confirmation and confirm the Confirmation Type is set to Page with the correct thank you page selected
  3. Scroll down to Pass Field Data via Query String
  4. Enter the following, replacing the field ID numbers with the actual IDs from your form editor (hover over each field in the form editor to see its ID):
value={Total:6}&freq={Billing Frequency:10}&plan={Subscription Level (Monthly):4}
  1. Click Save Confirmation

After a successful payment, the thank you page URL will carry the total like this:

https://yourdomain.com/thank-you/?value=%24+121.00&freq=Monthly&plan=Basic

Note: The numbers after the colon in each merge tag (e.g. :6, :10) are Gravity Forms field IDs specific to your form. These differ across installations. Always verify them in the form editor before saving.


Part 2 — Create GTM Variables

You need three variables in GTM: one to read the raw value from the URL, one to clean it into a plain number, and one to generate a unique transaction ID.

Variable 1 — Raw URL Parameter

  1. GTM → Variables → New
  2. Name: URL Param - value
  3. Type: URL
  4. Component Type: Query
  5. Query Key: value
  6. Save

Variable 2 — Clean Numeric Value

The URL carries the value as $ 121.00 with a dollar sign and space. GA4 requires a plain number. This variable strips the formatting.

  1. GTM → Variables → New
  2. Name: JS - Clean Value
  3. Type: Custom JavaScript
  4. Paste this code:
function() {
  var params = new URLSearchParams(window.location.search);
  var raw = params.get('value');
  if (!raw) return 0;
  return parseFloat(raw.replace(/[^0-9.]/g, ''));
}
  1. Save

Variable 3 — Unique Transaction ID

  1. GTM → Variables → New
  2. Name: JS - Transaction ID
  3. Type: Custom JavaScript
  4. Paste this code:
function() {
  return new Date().getTime().toString();
}
  1. Save

Part 3 — Create the GTM Trigger

  1. GTM → Triggers → New
  2. Name: Trigger - Thank You Page
  3. Trigger Type: Window Loaded
  4. Fire on: Some Window Loaded Events
  5. Condition: Page URL — contains — /thank-you-for-subscribing/
  6. Save

Why Window Loaded and not Page View? Window Loaded fires after all scripts on the page have fully initialised, including your GA4 configuration tag. Using Page View can cause the event to fire before GA4 is ready, resulting in hits that GTM records as sent but GA4 never receives.


Part 4 — Create the GA4 Event Tag

  1. GTM → Tags → New
  2. Name: GA4 Event - Subscription Purchase
  3. Tag Type: Google Analytics: GA4 Event
  4. For the Measurement ID, select your existing GA4 Google Tag from the container — do not type the ID manually. Inheriting from the config tag ensures the correct firing order.
  5. Event Name: purchase
  6. Add these event parameters:
Parameter NameValue
transaction_id{{JS - Transaction ID}}
value{{JS - Clean Value}}
currencyAUD
  1. Under Triggering, select Trigger - Thank You Page
  2. Save

Part 5 — Test Before Publishing

In GTM Preview:

  1. Click Preview in GTM
  2. Load the thank you page URL with test parameters:
https://yourdomain.com/thank-you/?value=%24+121.00&freq=Monthly&plan=Basic
  1. In the GTM debug panel, confirm the tag fires on the Window Loaded event
  2. Click the tag and check the eventSettingsTable shows value: 121 as a clean number with no dollar sign

In GA4 DebugView:

  1. GA4 → Admin → DebugView
  2. With GTM Preview still active, reload the thank you URL
  3. The purchase event should appear within 10–15 seconds with the correct value and currency parameters

Common issue — WP Rocket and caching plugins

If GTM fires correctly in Preview but GA4 never receives the event in a real browser session, check whether a performance plugin like WP Rocket has JavaScript delay enabled. Add googletagmanager.com/gtm.js to its exclusion list and clear the site cache before testing again.


Part 6 — Publish and Mark as a Conversion in GA4

Publish GTM:

  1. GTM → Submit
  2. Add a version name such as: Subscription purchase tracking
  3. Click Publish

Mark purchase as a conversion in GA4:

  1. GA4 → Admin → Conversions
  2. Click New conversion event
  3. Enter: purchase
  4. Save

GA4 recognises purchase as a standard ecommerce event and will automatically attribute the value parameter to revenue in your Monetisation reports.


Summary — Everything Created in GTM

TypeNamePurpose
VariableURL Param - valueReads raw value from URL query string
VariableJS - Clean ValueStrips dollar sign, returns plain number
VariableJS - Transaction IDGenerates unique ID per page load
TriggerTrigger - Thank You PageFires on Window Loaded for thank you URL
TagGA4 Event - Subscription PurchaseSends purchase event with value to GA4

This setup works for any Gravity Forms payment form that redirects to a static thank you page after Stripe processes the charge. The same approach applies to WooCommerce order confirmation pages or any other standard post-payment redirect — just adjust the URL query string and field IDs to match the platform.