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.
- Go to WordPress Admin → Forms → your form → Settings → Confirmations
- Open your existing confirmation and confirm the Confirmation Type is set to Page with the correct thank you page selected
- Scroll down to Pass Field Data via Query String
- 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}
- 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
- GTM → Variables → New
- Name:
URL Param - value - Type: URL
- Component Type: Query
- Query Key:
value - 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.
- GTM → Variables → New
- Name:
JS - Clean Value - Type: Custom JavaScript
- 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, ''));
}- Save
Variable 3 — Unique Transaction ID
- GTM → Variables → New
- Name:
JS - Transaction ID - Type: Custom JavaScript
- Paste this code:
function() {
return new Date().getTime().toString();
}- Save
Part 3 — Create the GTM Trigger
- GTM → Triggers → New
- Name:
Trigger - Thank You Page - Trigger Type: Window Loaded
- Fire on: Some Window Loaded Events
- Condition: Page URL — contains —
/thank-you-for-subscribing/ - 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
- GTM → Tags → New
- Name:
GA4 Event - Subscription Purchase - Tag Type: Google Analytics: GA4 Event
- 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.
- Event Name:
purchase - Add these event parameters:
| Parameter Name | Value |
|---|---|
transaction_id | {{JS - Transaction ID}} |
value | {{JS - Clean Value}} |
currency | AUD |
- Under Triggering, select
Trigger - Thank You Page - Save
Part 5 — Test Before Publishing
In GTM Preview:
- Click Preview in GTM
- Load the thank you page URL with test parameters:
https://yourdomain.com/thank-you/?value=%24+121.00&freq=Monthly&plan=Basic
- In the GTM debug panel, confirm the tag fires on the Window Loaded event
- Click the tag and check the eventSettingsTable shows
value: 121as a clean number with no dollar sign
In GA4 DebugView:
- GA4 → Admin → DebugView
- With GTM Preview still active, reload the thank you URL
- The
purchaseevent 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:
- GTM → Submit
- Add a version name such as: Subscription purchase tracking
- Click Publish
Mark purchase as a conversion in GA4:
- GA4 → Admin → Conversions
- Click New conversion event
- Enter:
purchase - 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
| Type | Name | Purpose |
|---|---|---|
| Variable | URL Param - value | Reads raw value from URL query string |
| Variable | JS - Clean Value | Strips dollar sign, returns plain number |
| Variable | JS - Transaction ID | Generates unique ID per page load |
| Trigger | Trigger - Thank You Page | Fires on Window Loaded for thank you URL |
| Tag | GA4 Event - Subscription Purchase | Sends 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.