Skip to main content

Configuring GA4 Ecommerce tracking via GTM in X-Cart

A
Written by Anna Verbichenko
Updated this week

Overview

X-Cart supports Google Analytics 4 (GA4) and Google Tag Manager (GTM) integrations via dedicated add-ons:

  • Google Analytics add-on (GA4)

  • Google Tag Manager add-on (GTM)

When the Send events via GTM option is enabled in the Google Analytics add-on, all ecommerce events (such as purchase, add_to_cart, etc.) are routed through GTM instead of being sent directly to GA4.

This approach:

  • Prevents double-counting of events

  • Ensures proper ecommerce parameter handling

  • Centralizes tracking logic inside GTM

However, when this option is enabled, you must configure corresponding GA4 event tags inside GTM. Otherwise, ecommerce events will not appear in GA4.


Step 1: Configure Google Tag Manager in X-Cart

  1. Go to GTM Settings in your X-Cart Admin area.

  2. Enter your GTM Container ID.

  3. Save changes.

If GTM is not configured, the Send events via GTM toggle will be visible but disabled.

Tooltip message:

  • To enable this option, please provide a Container ID in the GTM Settings page first.


Step 2: Enable “Send events via GTM”

  1. Open the Google Analytics add-on settings.

  2. Enable the Send events via GTM option.

Tooltip message:

  • Enable this to route all ecommerce data (purchases, add to cart, etc.) through GTM instead of sending it directly to GA4. This prevents double-counting and ensures correct data flow.


Why Ecommerce events may not appear in GA4

After enabling Send events via GTM, some merchants notice that:

  • Standard events like page_view are tracked

  • Ecommerce events like purchase or add_to_cart are missing

This happens because:

  • X-Cart pushes ecommerce data into the dataLayer

  • GTM must be configured to listen for those events

  • Corresponding GA4 Event Tags and Triggers must exist in GTM

Without proper GTM configuration, ecommerce events will not be sent to GA4.


Step 3: Create the base Google Tag

Before creating GA4 event tags, make sure that your GTM container includes the base Google Tag. This tag initializes GA4 on your website and allows all subsequent event tags to send data to Google Analytics.

If your container already has a Google Tag configured, you can reuse it and skip this step.

To create the base Google Tag:

  1. Open Google Tag Manager.

  2. Go to Tags → New.

  3. Click Tag Configuration.

  4. Select Google Tag.

  5. In the Tag ID field, enter your GA4 Measurement ID
    (for example: G-XXXXXXXXXX).

  6. Under Triggering, select:

    All Pages
  7. Save the tag.


Step 4: Create a GA4 event tag in GTM

You must create a specific tag for each ecommerce action (purchase, add to cart, etc.). For the sake of example, we'll create a tag for purchase.

A. Create a new tag

  1. Open Google Tag Manager.

  2. Go to Tags → New.

  3. Click Tag Configuration.

  4. Select:

    Google Analytics → Google Analytics: GA4 Event
  5. In the Measurement ID field, enter your GA4 ID (starts with G-).

  6. In the Event Name field, enter:

    purchase

Event names must match GA4 recommended event names:
https://support.google.com/analytics/answer/9267735


B. Enable Ecommerce data

Inside the same Tag configuration:

  1. Scroll to More Settings.

  2. Open Ecommerce.

  3. Check the box Send Ecommerce data.

  4. Set Data Source to:

    Data Layer

Enable Ecommerce data sending in GA4

This ensures that all ecommerce parameters (items, value, currency, etc.) are correctly sent to GA4.


Step 5: Create a trigger

Now configure when the tag should fire.

  1. Click the Triggering box at the bottom.

  2. Click the + icon to create a new trigger.

  3. Select Trigger Configuration → Custom Event.

  4. In the Event name field, type the name of the event; in our case:

    purchase
  5. Save the trigger.

  6. Save the tag.

  7. Publish your GTM container.

Trigger configuration in GA4


Step 6: Repeat for other Ecommerce events

You must repeat this process for each ecommerce event you want to track, including:

  • add_to_cart

  • remove_from_cart

  • view_item

  • view_cart

  • begin_checkout

  • and any other ecommerce steps

Each event requires:

  • A GA4 Event Tag

  • A Custom Event Trigger

  • Ecommerce enabled

  • Exact event name match

Check the Tags and Triggers tabs to ensure you have everything in place:

Triggers

Tags


Required events mapping

X-Cart Action

GTM Event Name

Description

Item View

view_item

Product page visit

Add to Cart

add_to_cart

Clicking the buy button

+1

Remove from Cart

remove_from_cart

Removing an item from the shopping cart

+1

View Cart

view_cart

Visiting the cart page

Purchase

purchase

Successful order completion


Step 7: Test and verify your tracking

Before going live, verify that your GTM and GA4 setup works correctly.

A. Validate in GTM Preview Mode

  1. In Google Tag Manager, click Preview.

  2. Enter your storefront URL to open the GTM Debugger.

  3. Place a test order.

  4. In the Debug panel:

    • Confirm that the purchase event appears.

    • Ensure the GA4 Event Tag status is Succeeded.

    • Verify that ecommerce parameters are present.

This confirms that GTM is correctly receiving and processing the event.

B. Confirm in GA4

  1. Open Google Analytics 4

  2. Go to:

    Home → Reports → Realtime overview
  3. Verify that:

    • The purchase event appears.

    • Transaction value is displayed.

    • Product items are included.

This confirms that GA4 receives complete ecommerce data.

We recommend verifying all your ecommerce events, not only purchase.
This ensures that the entire ecommerce tracking flow is configured correctly

Realtime overview


Can't find answers you're looking for?

Email us at support@x-cart.com. We will be happy to help!


Related articles

Did this answer your question?