<img alt="" src="https://secure.365-visionary-insightful.com/791573.png" style="display:none;">
Skip to content
English
  • There are no suggestions because the search field is empty.

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)

  1. In GTM, click TagsNew
  2. Choose Tag Type: Google tag
  3. Enter your GA4 Measurement ID (e.g., G-XXXXXXXXXX)
  4. Trigger: All Pages
  5. 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

  1. In GTM > Tags > New
  2. Choose Tag Type: Google Analytics: GA4 Event
  3. Event Name: purchase
  4. Configuration Tag: select your Google tag
  5. 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

  1. Click Preview in GTM
  2. Enter your Thank You page URL
  3. Complete a test booking
  4. 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

  1. Go to GA4 > Admin > DebugView
  2. Confirm the purchase event appears
  3. 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.