Google Analytics 4 (GA4) eCommerce dataLayer – How is It Different from UA

If your GA4 eCommerce data is partially complete then you might be experiencing some dataLayer issues. Read on for a fix.

GA4 eCommerce Not Working

The last 10 years have seen a huge shift in charities adopting digital channels as part of their fundraising, advocacy and even for delivery of services to the beneficiaries.

Understanding how users interact with a website and from a fundraising perspective, tracking donations has become increasingly important for charities. This is where data tracking tools like Google Analytics come in. However, with the release of Google’s new GA4 data model, there are some significant changes that charities need to be aware of.

In this article, we will explore the key differences between the UA (Universal Analytics) and GA4 data layer (or dataLayer as it’s written in your HTML), specifically focusing on how charities can use these tools to understand supporters better.

What is a data layer?

Before diving into the differences between UA and GA4 data layers, let’s first talk about what a data layer actually does. A data layer is a JavaScript object placed on a website’s pages to capture important data about user interactions. Analytics tools like GA and UA can then use this data to provide insights into user behaviour.

The UA data layer

Universal Analytics, or UA, is the older of the two data layer models. The UA data layer has been widely used by charities to track donations and virtual gifts. The data layer is designed to capture information about the user’s interactions with the website and the donation they make. This includes data like the donation amount, product ID, product category, and whether the donation is one-off or recurring.

For example, the following code can be used to track a one-off donation in UA:

dataLayer.push({
    'ecommerce': {
    'purchase': {
      'actionField': {
        'id': 'T12345',                         
        'affiliation': 'Online Store',
        'revenue': '150',                     
        'tax':'0',
        'shipping': '0',
             },
      'products': [{                            
        'name': 'End of Financial Year Appeal',     
        'id': '12345',
        'price': '150',
        'brand': 'EOFY',
        'category': 'One-off Donation',
        'quantity': 1,                   
         }]
    }
  }
});

In this example, the data layer captures the donation amount ($150), product ID, product category, and that the donation is a one-off donation. Hopefully, by now, you can start to see why this data is so useful, particularly in:

  • Determining the volume of donations received
  • Understanding the value of the donations received (revenue)
  • Showing us the name of the appeal/campaign that the supporting is donating to
  • Giving us visibility of the type of donation – i.e. whether it’s one-off or monthly

The above information can be highly valuable when optimising digital marketing/fundraising campaigns to drive more value. For instance, understanding whether a marketing channel provides more one-off or monthly donations may impact decisions on how marketing investment is directed.

The GA4 data layer

Google Analytics 4, or GA4, is a newer data layer model released by Google in 2020. GA4 is designed to provide a more holistic view of user behaviour across different platforms, including mobile apps, web, and offline interactions and future-proof the platform against the changing landscape for user privacy.

The GA4 data layer is similar to UA but includes additional features like the ability to send through multiple levels of category information with an eCommerce transaction.

As an example, the following code can be used to track a recurring donation in GA4:

dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "purchase",
  ecommerce: {
      transaction_id: "T_12345",
      value: 150,
      currency: "AUD",
      items: [
       {
        item_id: "SKU_12345",
        item_name: "End of Financial Year Appeal",
        index: 0,
        item_brand: "EOFY",
        item_category: "One-off Donation",
        item_category2: "PayPal",
        item_category3: "In Memory - TRUE",
        price: 150,
        quantity: 1
        }]
  }
});

As you can see from the above example, the GA4 dataLayer looks similar but has some subtle differences from that used to trigger an eCommerce transaction in UA. For example:

  • In GA4, you use transaction_id not id
  • In GA4, it’s value not revenue
  • In GA4, it’s item_name not product name
  • In GA4, it’s item_category not product category
  • With GA4, you can now have multiple layers of category information which can be used for identifying things like payment method used (PayPal in the example above), whether or not somebody has selected that their donation is “in memory” etc.

Although, on the surface, these seem like minor naming convention changes, it’s vitally important that they’re applied correctly for GA4 to capture all of your data.

Need help configuring Google Analytics 4?

Our Google Analytics specialists will help you get your Google Analytics 4 account set up and firing on all cylinders. We can also help you explore alternatives to GA4 and get even more insight to improve your digital performance.

    Jon Dawson, CEO of Digital Ninjas
    Jonathan will get back to you soon

    Why is my GA4 property recording volume and value but not item names or categories?

    We’ve seen a few examples of GA4 users seeing purchases logged in GA4 but no item names or revenue. If your Monetisation overview screen looks a bit like the below, then you may be experiencing this issue:

    GA4 ecommerce not working - recording partial incomplete data

    When we’ve looked more closely at what’s causing the issues, the answer is almost always with some inconsistency with the way the dataLayer is constructed. In this scenario, it’s likely that revenue and/or item quantity may not have been defined as an integer. For example:

    The correct way to do it:

    {
            item_id: "SKU_12345",
            item_name: "End of Financial Year Appeal",
            index: 0,
            item_brand: "EOFY",
            item_category: "One-off Donation",
            item_category2: "PayPal",
            item_category3: "In Memory - TRUE",
            price: 150,
            quantity: 1
            }]

    The incorrect way to do it:

    {
            item_id: "SKU_12345",
            item_name: "End of Financial Year Appeal",
            index: 0,
            item_brand: "EOFY",
            item_category: "One-off Donation",
            item_category2: "PayPal",
            item_category3: "In Memory - TRUE",
            price: "150",
            quantity: "1"
            }]

    Did you spot the difference? No?! It’s subtle; note the ” ” in the incorrect example around the price and quantity. This changes the parameter from an integer to a string and results in GA4 only ingesting the purchase event itself and not the value or product details.

    When things are working correctly this is how your Monetisation Overview dashboard should look:

    GA4 eCommerce working as expected - item name, reveneu and quantity now populating

    Summary

    As you can see, the eCommerce dataLayer helps provide vital insight on campaign performance for charities. However, there are important differences between how the UA and GA4 data layers are implemented that need to be considered.

    Understanding these differences and ensuring some of the more common implementation mistakes are avoided can make the difference between a rich data set to power your decision-making and only getting partial data resulting in confusion and decision paralysis.