Get Started Get Started

Setting Up Google Analytics 4 E-commerce Tracking

When a customer reaches the order success page, Oncord sends a Google Analytics 4 purchase event with the order number, total, tax, shipping and the items bought. This guide is for online store owners who want to see their orders and revenue in Google Analytics 4.

Before You Begin

Install one of these on your website, not both:

  • Google tag (gtag.js) - Follow Google Analytics 4.
  • Google Tag Manager - Follow Google Tag Manager. You also need a Google Analytics 4 property with a web data stream, which the Google Analytics 4 article covers.

With two copies of the tag, every page view is counted twice. Add the code to the design your checkout pages use: code added to one design only runs on pages that use that design.

If You Are Using Google Tag (gtag.js)

There is nothing else to set up. Once the Google tag is in the design your checkout pages use, Oncord sends the purchase event from the order success page.

Google Analytics marks purchase as a key event by default. To check this:

  • Sign in to Google Analytics.
  • Click Admin at the bottom left.
  • Under Data display, click Events.
  • Open the Key events tab.

If You Are Using Google Tag Manager

Oncord adds the purchase event and the order details to the data layer on the order success page. In Google Tag Manager, you create a Google tag that loads Google Analytics, a trigger for the purchase event, and a tag that sends the order details to Google Analytics.

You need your Google Analytics 4 Measurement ID for Steps One and Three. The steps to find it follow Step One.

To start:

Step One: Create the Google Tag

If your container already has a Google tag for your Google Analytics 4 property, skip to Step Two.

  • Click Tags in the left menu.
  • Click New.
  • Enter a tag name, such as GA4 Google Tag.
  • Click Tag Configuration.
  • Select Google Tag.
  • Enter your Measurement ID in the Tag ID field.
  • Click Triggering.
  • Select Initialization - All Pages.
  • Click Save.

To find your Measurement ID:

  • Sign in to Google Analytics.
  • Click Admin at the bottom left.
  • Under Data collection and modification, click Data streams.
  • Select the Web tab.
  • Click the data stream for your website.
  • Copy the Measurement ID from the Stream details. It starts with G-.

Step Two: Create GA4 E-commerce Event Trigger

  • Click Triggers in the left menu.
  • Click New.
  • Enter a trigger name, such as GA4 E-commerce Event.
  • Click Trigger Configuration.
  • Select Custom Event.
  • Enter purchase in the Event name field, in lowercase.
  • Click Save.

Step Three: Create GA4 E-commerce Tag

  • Click Tags in the left menu.
  • Click New.
  • Enter a tag name, such as GA4 E-commerce Tag.
  • Click Tag Configuration.
  • Select Google Analytics: GA4 Event.
  • Enter your Measurement ID in the Measurement ID field.
  • Enter purchase in the Event Name field.
  • Click More Settings.
  • Under Ecommerce, tick Send Ecommerce data.
  • Select Data Layer as the Data Source.

Step Four: Assign the Trigger

  • Click Triggering.
  • Select GA4 E-commerce Event.
  • Click Save.

Step Five: Publish Your Changes

Your tags only start working once you publish the container.

  • Click Submit at the top right.
  • Click Publish.

View the Results

An order is only recorded when the customer reaches the order success page and their browser allows the tracking code to run. Place a test order and check that it appears before relying on the results.

To see the purchase events:

  • In Google Analytics, go to Reports > Engagement > Events.
  • Find purchase in the list, or search for it.

To see revenue and the products sold, go to Reports > Monetisation.

Note: New orders can take up to 48 hours to appear in these reports. To check a test order sooner, open the Realtime report, which shows events from the last 30 minutes.