Tracking GA4 Custom Events Via Tag Manager

WebAlliance uses Google Analytics 4 (GA4) via Tag Manager.  In order to utilize GA4, you must first configure Google Tag Manager (GTM).

GTM allows you to have a centralized place to store third-party scripts in one manageable and efficient location.  It also allows for the transmission of ‘datalayer’ data that can be used to track specific events.  You’ll see a list of events and sample data payloads in our document found at the end of this article.

Getting Started

You must first create a GA4 Configuration Tag to follow this document exactly.  You can see a complete guide on setting up GA4 (including the Configuration Tag) in our Google Analytics 4 Setup Video and Walkthrough article. 

Once your GA4 Configuration tag is in place, you are ready to begin.

Note that our sample below shows the configuration of a custom event.  This should provide a guide to follow for implementing any other custom events supported by WebAlliance.  Many other options are available with GA4 and GTM; however, those are beyond the scope of this document. 

We recommend seeking out specialized help from a qualified source in completing the setup of GA4.  GA4 is much more complex than the previous Google Universal Analytics. 

If you want a simple, affordable alternative to track website stats, we have found that Plausible Analytics is a good fit.  It is easy to configure and use.  You can read more about Plausible at: https://plausible.io/.

Support and configuration of third-party systems, including GA4 and GTM are beyond the scope of our support.  We have created this document to help our customers, however, it is possible and likely that it will become outdated as Google makes changes to its platforms.  It is accurate as of April 2023.

Sample Custom Event Setup

The following steps walk you through using a custom event (Login) which will fire every time a user logs in.  The custom login event can track the customer’s username which can be useful for certain scenarios.

From your Tag Manager home screen, select "New Tag", and then Tag Configuration.

Select Google Analytics: GA4 Event as the Tag Type

  1. Create a new Tag with a type of Google Analytics: GA4 Event to be used for this process.
  2. Enter an Event Name for this tag.  Note:  This will appear on your reports; we recommend using the Event Name that is the same as the event ("Login" in this case).
  3. Click the Add Row button to define the parameters.
  1. Enter the parameter name for the event.  This should typically be the same as the value you are using from the event payload.  (you can find the events and event payloads document at the end of this article)
  2. Click the building block icon to allow us to create a variable for our event payload data.
  1. Click the + button to create a new variable.
  1. Enter a name for your variable.  We typically recommend using the same name as the parameter name you used when configuring the parameter.  Ultimately, you can use any name you want and will be able to select it from a list in future steps.
  2. Click in the Variable Configuration area to set up the variable.
  1. Choose a variable type of “Data Layer Variable”
  1. Enter the data layer variable name.  For the login object the proper variable name is ‘username’.
    NOTE:  This variable name must exactly match the data object name from the GA4 Custom Events detail sheet found at the end of this article.  This uses nested object notation meaning that if the data layer is inside another level of data the object would need to specify the parent and the detail.  See the GA4 Custom Events details and sample payloads to get a specific variable name.
  2. Click the Save button to submit your new variable definition.
  1. Select the variable you just created from the list.  You may click the block button to see a list of variable names.
  2. Click the Triggering area to generate a new trigger.
  1. Click the plus button to make a new trigger.
  1. Provide a name for the trigger
  2. Click in the Trigger Configuration area to configure the new trigger.
  1. Click Customer Event for the trigger type
  1. Enter an Event Name ("Login" in our example).  We recommend your event name be the same as your trigger name.
  2. Click "Some Custom Events".
  3. Select "Event".
  4. Select "equals".
  5. Enter the Event Name (‘login’ in our example).
    NOTE:  The Event Name must exactly match the Event Name on the GA4 Custom Events document for the event you are trying to utilize.
  1. Your new Tag should appear in the Tag Manager Tags list.
  2. Click "Submit" to save your changes.
  1. Supply a brief description of the new Tag Manager change.
  2. Click "Publish" to start using the new Tag and tracking the custom GA4 event.