Google Analytics

Using Google Tag Manager with Google Analytics 4 and Ecommerce

Introduction

This document outlines how to set up Google Tag Manager (GTM) with Google Analytics 4 (GA4) for existing and new installs.

There are two options for implementing Google Analytics:

  • Option 1 - copy the GA snippets provided at the end of the setup in one of the custom fields in Settings.
  • Option 2 - use the Google Tag Manager feature in Settings > General > Google Tag Manager.

This guide focuses on using GA4 with GTM, including e-commerce support.

Announcement - Google Analytics 4 has replaced Universal Analytics - July 1, 2023.

New GTM / GA4 Setups

Step 1: Setup Google Analytics

  1. Go to Google Analytics.
  2. Create a new account, follow these steps from Google (for an existing site or a new site).
  3. Note the Measurement ID on the final step or go into Admin > Data Streams > your stream name > you will see the Measurement ID under Stream details. You will need the Measurement ID to add to Google Tag Manager.

Step 2: Setup Google Tag Manager (new setup)

  1. Go to Google Tag Manager.
  2. Create a Google Tag Manager account. Make a note of the Container ID and add it to Retreat Guru in Settings > General > Google Tag Manager > Container ID.

GA4-1

  1. You will now need to add GA4 into GTM - to do this, create a new “Google Analytics: GA4 Configuration” tag.
    1. Set the measurement ID to the previously recorded Measurement ID.
    2. Create a trigger for “All Pages.”

GA4-2

  1. Save the tag.
  2. Your GA4 is now ready to track. At this point, it is recommended to test that your Google Analytics account is tracking. You can do this by Submitting your Tag Manager changes.
  3. Go to one of your registration pages to see activity in your Real-Time reporting in GA4.

GA4-3

Step 3: Create the event tag:

To enable e-commerce tracking, you must set up Google Tag Manager to trigger the “purchase” event from registrations created in Retreat Guru.

Create the trigger first; this is what will execute this tag.

  1. Go into Triggers > New.
  2. Give the trigger a name like “Product purchase.”
  3. Set the Trigger Type to Custom Event.
  4. Set the Event name to “confirmation” (the DataLayer event we send from the registration create process).
  5. Set “This trigger fires on” to “All Custom Events.”
  6. Click Save.

GA4-4

Create the event tag

  1. Go to Tags > New.
  2. Create a new “Google Analytics: GA4 Event” tag.
  3. Set the “Configuration Tag” to your Google Analytics tag name.
  4. Set the “Event Name” to “purchase.” This is what GA4 wants to trigger a purchase transaction in GA4.
  5. Under “More Settings” → “Ecommerce,” check “Send Ecommerce data” and make sure the Data source is set to “Data Layer.”
  6. You do not need to specify any event parameters, e.g., variables.
  7. Under “Triggering,” set the trigger to the one you just created.

It should look like this:

GA4-5

Click Save and then click “Submit” to publish your changes.

You can now create a demo program in Retreat Guru and submit a registration. You should see activity in your Real-Time reporting and a conversion. Note that it takes about 24 hours for the e-commerce reports/monetization reports to update.

Debugging

Debugging is documented via Google here and here. The recommended approach is to put GTM into Preview mode, and then when you connect, the page will load and trigger the purchase event in GA’s Debug View. You can also use the GTM debugging view to see the data layer and events triggered.

back to TOP

 

Migrating Existing Universal Analytics to GA4 (with GTM)

If you have UA set up with GTM, the migration will require you to check a few things. You should also refer to this documentation from Google: https://support.google.com/analytics/answer/9744165

If you used us before for GTM, most of the setup is done, but the most significant difference will be that you need to set up a GA4 Event tag for the “purchase” event.

  1. Ensure that you have GA4 setup in GTM - you must create a new tag (see above GTM instructions). Also, check that GTM is streaming data into your GA4 account.
  2. If you followed our older GTM instructions, you will already have a trigger for the “confirmation” event. So you will not need to create one.
  3. You will want to create a “Google Analytics: GA4 Event” tag. See the instructions above. Ensure to check that your configuration matches. Set the trigger to the “confirmation” trigger previously created. Don’t forget to enable the E-commerce data layer option to track purchases.
  4. That’s it! You can now Submit your changes and test them with a hidden test program.

 

Additional DataLayer Variables

See Google's tag-manager/devguide. Retreat Guru passes a wide range of information in a data layer object.

Whenever your guest is on the Retreat Guru platform, for example, the online registration form or the guest statement page, Retreat Guru passes a pageCategory to indicate which page the viewer is on. The pageCategory will have one of these possible values:

  • confirmation - guest is on Retreat Guru registration thank you page.
  • waiting-list - guest is on the Retreat Guru waiting list form.
  • waiting-list-confirmation - guest is on the Retreat Guru waiting list thank you page.
  • registration - guest is on the Retreat Guru online registration form.
  • guest-edit - guest is on the Retreat Guru guest edit page.
  • guest-edit-confirmation - guest completes Retreat Guru guest edit page.
  • program - guest is on Retreat Guru program page.
  • guest-statement - guest is on Retreat Guru guest statement page.
  • program-listing - guest is on Retreat Guru program listing page.
  • teacher-listing - guest is on Retreat Guru teacher listing page.
  • teacher - guest is on Retreat Guru teacher details page.

For transactions, Retreat Guru passes the following into the data layer object:

  • checkInDate - guest’s check-in date.
  • checkOutDate - guest’s check-out date.
  • transactionId - registration’s transaction ID.
  • transactionTotal - the amount paid on the registration.
  • transactionProducts - an object that contains the name, price, quantity, and SKU), for example:
    • transactionProducts.0.sku - the program ID.
    • transactionProducts.0.name - program name.
    • transactionProducts.0.price - amount paid on the registration.
    • transactionProducts.0.quantity - we always pass 1.

How do I pass data (like program name, SKU, or totals) into other types of tags, like a Custom HTML snippet?

These are advanced settings intended for use by professional developers or analytics experts. These features may require customization or code modification by the third-party analytics/tracking service.

In some cases, you may want to pass data of the registration into other types of tags. For example, you may be using a Custom HTML snippet tag to embed a Facebook tracking pixel and want to pass in additional information like SKU, program name, and totals.

Here’s an example of how you may want to use these variables in a custom HTML snippet tag - in this example, we’re passing transactionTotal (listed above) to the Facebook tracking pixel:

<script>



fbq('track', 'ViewContent', {

    content_type: 'product',

    content_ids: [‘’],

  value: {{*transactionTotal*}},

    currency: 'USD' //REQUIRED if you a pass value

});



</script>

 

Troubleshooting

  • I don’t see any purchases in my reports

    Please allow up to 24 hours for purchases to show up after configuring your GA4/GTM platform. We also suggest double-checking the entire setup and using the “DebugView” feature in GA4 to ensure that the “purchase” event is triggered when a registration is created.

    You can create a draft or hidden program to accomplish this testing.

    Make sure you have “Ecommerce” > “Send Ecommerce data” checked and the Data source set to “Data Layer”.

    Also, ensure that the currency set in GA4 matches the currency set in your booking software. For example, if your booking software is GBP, you must set the currency in GA4 to GBP.

    Another thing to check for is to ensure the connection between GTM and GA4 is streaming data. You can check the Real-Time report in GA4 and load up the registration page. You should see a view event. If you don’t see this, then there is a problem with your initial GTM configuration with GA4.

  • Why do I see a drop-off between my site and the registration form hosted by you?

    Please turn on the cross-domain measurement option. You can see the official Google documentation here.

  • I can’t see any item-viewed events or other events listed in the e-commerce documentation from Google.

    We currently only provide the “purchase” event; in the future, we may consider other events.

  • What about taxes, coupons, and other fields? Are those included?

    Currently, these are not included. Taxes are reflected in the value (we get it from the grand total). We may consider adding these In the future.

  • How long can I use Universal Analytics?

    We have not removed any of the original UA variables, but we have also included the GA4 variables alongside e-commerce support in GA4. This is to allow for backward compatibility.

  • Can you provide us with an exported container that we can import?

    We will eventually create an importable configuration for convenience similar to the current one provided with our GA/GTM documentation.

  • Does Retreat Guru’s implementation of GA4 work with Remote Registration or Quick Add registration?

    Not at this time

  • Can you set up our GTM and GA4 and our other tracking tools?

    We can help you debug minor issues around your setup but the GA4 and GTM setup should be completed by your data and analytics expert/consultant/3rd party or internal development team.

back to TOP


rg-favicon-32 Questions? Contact your friendly support guru.