How to Set Up GA4 Ecommerce Tracking with Google Tag Manager in TrekkSoft
This article explains how to set up GA4 ecommerce tracking with Google Tag Manager in your TrekkSoft booking flow. It covers how purchase events are captured and sent to GA4 for accurate reporting
Last Update: January 13, 2026
Prerequisites:
- A GA4 property and Measurement ID (e.g., G-XXXXXXXXXX)
Step 1: Add the Google Tag (GA4 Configuration)
- In GTM, click Tags > New
- Choose Tag Type: Google tag
- Enter your GA4 Measurement ID (e.g., G-XXXXXXXXXX)
- Trigger: All Pages
- Save and publish
This should load GA4 on every page and enables automatic page_view tracking.
Step 2: Push Purchase Data to the dataLayer
On your Thank You page, insert the following script. You can also place it on your Checkout, Taxes & Fees page:
<script>
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: "purchase",
eventModel: {
transaction_id: "",
value: ,
currency: "",
tax: ,
items:
}
});
</script>
TrekkSoft will enter real booking data into this script. The eventModel object should contain all ecommerce parameters.
Important: Your Booking Data Is Nested Inside Event Model
In TrekkSoft, booking values are nested inside eventModel. Make sure your GTM variables reference keys like eventModel.transaction_id instead of looking at the top level
Example:
eventModel: {
transaction_id: "30318258",
affiliation: "richardtravels",
value: 0,
currency: "USD",
tax: 0,
items: [
{
id: "activity-80934",
name: "Normal Schedule Test",
variant: "31 October, 2025, 08:00",
price: 10,
quantity: 1
}
]
}
Step 3: Create GTM Variables to Read the Data
In GTM > Variables > New, create the following Data Layer Variables:
|
Variable Name |
Data Layer Key |
Type |
|
Booking ID |
eventModel.transaction_id |
Data Layer Variable |
|
Booking Total |
eventModel.value |
Data Layer Variable |
|
Booking Currency |
eventModel.currency |
Data Layer Variable |
|
Booking Items |
eventModel.items |
Data Layer Variable (array) |
Make sure to set Version 2 for each variable.
Step 4: Create the GA4 Purchase Event Tag
- In GTM > Tags > New
- Choose Tag Type: Google Analytics: GA4 Event
- Event Name: purchase
- Configuration Tag: select your Google tag
- Event Parameters:
transaction_id:value:
currency:
items:
6. Trigger: Custom Event
-
- Event Name: purchase
- Fires on: All Custom Events
7. Save
This tag passes the purchase data to GA4 whenever the purchase event runs.
Step 5: Test in GTM Preview Mode
- Click Preview in GTM
- Enter your Thank You page URL
- Complete a test booking
- Check if these events appear:
- The purchase event appears in the left panel
- Your GA4 Event tag fires
- Variables show correct values
Step 6: Validate in GA4 DebugView
- Go to GA4 > Admin > DebugView
- Confirm the purchase event appears
- Check if these parameters appear:
- transaction_id
- value
- currency
- items array
Step 7: Publish Your GTM Container
Once everything works:
- Click Submit in GTM
- Name your version (e.g., “GA4 Ecommerce Tracking Live”)
- Click Publish
Troubleshooting Tips
- If variables show “undefined,” confirm your dataLayer.push() runs after GTM loads
- Ensure the keys match exactly (e.g., transaction_id, not transactionId)
- Always test with a full booking flow, skipping directly to the Thank You page may result in missing data or even using 100% discount codes may cause inconsistencies. We highly suggest making a real test booking and refunding that booking afterwards.