How to Set Up Analytics for Your Online Store Using Google Tag Manager

Contents:
Promoting your online store becomes much easier when you understand your customers’ behavior.

Imagine a customer visits your website, views a product, adds it to their cart — but then leaves without completing the purchase. You don't know why they left. To find out and improve your website, you need detailed data about each action your customers take: what they looked at, what they chose, and most importantly, at what step they decided to leave.

In this article, we’ll explain step-by-step how to use Google Tag Manager (GTM) to track every customer action — from product views to completed orders. This way, you'll clearly see what prevents customers from buying and how to fix it.

What is Google Tag Manager, and why do you need it?

Google Tag Manager is a free tool from Google. It lets you easily add and manage tracking codes on your website without relying on a programmer. Everything is done through an easy-to-use interface.
Previously, to know who clicked the “Buy” button, you needed a developer to insert special code. With GTM, you can set this up yourself in just a few clicks.

With GTM, you can track important actions, such as:

  • Which products customers view most often;
  • Items that customers add to their carts;
  • Steps in the checkout process where customers leave;
  • Products customers buy, and products they ignore.

How Google Tag Manager works

Your website collects customer actions and stores them in a special place called the dataLayer.

Think of the dataLayer as a detailed notebook where your site records customer actions like “Customer viewed running shoes,” “Customer added item to cart,” or “Customer left during payment.”

For websites from 4Partners, this dataLayer is already built-in. You only need to set up how this information is sent to Google.

Google Tag Manager itself doesn't analyze the data — it only gathers it. To turn this collected data into clear insights, you need Google Analytics. GTM sends detailed information there, such as:

  • Products viewed by customers;
  • The total value of purchases;
  • The checkout stage at which customers leave.

As a result, you receive a clear picture of your visitors’ behavior and can make decisions based on accurate data rather than guesses.

How to set up Google Tag Manager

Step 1. Activate data collection

First, open Google Analytics, go to Admin → Data Streams, and enable the “Enhanced measurement” option. This allows Google Analytics to start collecting detailed data about your users.

Step 2. Set up Google Tag Manager on your site

If Google Tag Manager hasn't been installed yet, a developer should do it once by adding a specific code to your website. After that, you’ll manage everything easily yourself using the GTM interface. Alternatively, you can contact 4Partners’ support—we can help set up GTM for free.

Step 3. Specify what actions you want to track

Inside Google Tag Manager, clearly indicate what user actions you want to track, such as:

  • Viewing a product;
  • Adding products to the cart;
  • Starting the checkout process;
  • Completing a purchase.

GTM provides ready-made templates—you simply select what you need, just like filling out a form.
  1. Go to Google Tag Manager → Variables.
  2. Click "New".
  3. Name it clearly, e.g., “GTM E-commerce DataLayer”.
  4. Set the variable type as “Data Layer Variable”.

This variable captures key information from your website, such as products in the cart, delivery costs, or the order number.
Example:
Examples of useful variables:

  • ecommerce.items — List of products ordered.

  • ecommerce.value — Total purchase amount.

  • ecommerce.shipping — Delivery cost.

  • ecommerce.currency — Currency of the purchase.

  • ecommerce.affiliation — Your store’s name.

  • ecommerce.transaction_id — Order number.

Step 4. Send your data to Google Analytics

Next, you'll configure GTM to pass this collected data into Google Analytics. Within GTM, you'll set an action (for example, "purchase"), indicate where data should go, and save your settings.

Effectively, you're telling the system: “If a customer completes a purchase, send data to Google Analytics, including what was bought, the purchase value, and shipping costs.”
Create two tags:

Tag 1: Tracking customer actions before purchase

  1. Name: GA4 - GTM_without_purchase
  2. Type: GA4 Event
  3. Event Name: {{Event}}
  4. Parameter: items = {{ecommerce.items}}

This tag tracks actions like viewing products, adding to cart, and starting checkout—everything except the actual purchase.

Tag 2: Tracking the actual purchase

  1. Name: GA4 - GTM_purchase
  2. Type: GA4 Event
  3. Event Name: purchase
  4. Parameters (example code):

gtag('event', 'purchase', {
  items: {{GTM ecommerce.items}},
  transaction_id: {{GTM ecommerce.transaction_id}},
  affiliation: {{GTM ecommerce.affiliation}},
  value: {{GTM commerce.value}},
  shipping: {{GTM ecommerce.shipping}},
  currency: {{GTM ecommerce.currency}}
});

This provides detailed insights into exactly what customers bought, the cost, and delivery information.
Example:

Step 5. Set triggers (when tags activate)

Triggers are conditions that tell GTM when to send data.

For Tag 1 (actions before purchase):

  • Name: GA4 - GTM_ecommerce_events_purchase

  • Type: Event

  • Triggered by these events:

view_item_list | select_item | view_item |
add_to_cart | remove_from_cart |
begin_checkout | add_payment_info
Important: Do not include the purchase action here, as it will have its own separate trigger.

For Tag 2 (purchase):

  • Name: purchase

  • Type: Event

Key Takeaways

To understand why customers abandon their carts, you need to track their actions—from viewing a product to completing an order.

Google Tag Manager allows easy tracking of customer actions without programming skills, through an intuitive interface.

With GTM, you can clearly see popular products, cart actions, checkout issues, and completed sales.

Customer actions are stored in the dataLayer, and you control exactly what is collected.

To share this data with Google Analytics, create tags and set when they should activate.

For completed purchases, create a special separate tag providing detailed insights on purchases, prices, and delivery.
SUBMIT
Submit your request, and our expert will contact you soon to guide you through all the details and offer tailored advice