How to Send Custom Events & Parameters to GA4

The power of GA4 lies in your ability to send custom data to the platform. ListenLayer enables this for everyday marketers by automating powerful data layer activity without any programming required! Let's take a look at how easy this is!

Customizing GA4 with Events & Parameters Using ListenLayer and GTM

It’s time to stop using Google Analytics 4 out of the box and start to enhance your data collection and web analytics.  Use ListenLayer to power your custom events and parameter easily!

Steps & Code Examples

Step 1: Add Your Domain Name Inside ListenLayer
Step 1: Add Your Domain Name Inside ListenLayer

Navigate to the Website screen of your ListenLayer account and add your website domain name. Then copy the Website Script to place on your website using Google Tag Manager.

Step 2: Deploy Your ListenLayer Website Script
Step 2: Deploy Your ListenLayer Website Script

Create a Custom HTML Tag inside of Google Tag Manager that fires on All Pages. Place the tracking script from your ListenLayer account. A sample is shown here, but you must use the code from your account, not this example code!

<script type="text/javascript">(function(c,a,d,b,e) {c[b] = c[b] || [];
c=a.getElementsByTagName(d)[0];a=a.createElement(d);b="dataLayer"!= b ?"&l="+b:"";a.async = !0;
a.src = "https://assets.listenlayer.com/datalayer.min.js?id="+e+b;
c.parentNode.insertBefore(a,c)})(window,document,"script","dataLayer",
"00000000-0000-0000-0000-0000000000000");</script>
Step 3: Enable Your Listener & Features
Step 3: Enable Your Listener & Features

Enable Listeners for your website so that you can begin to capture user activity into the browser’s data layer automatically. This is the first step to being able to send custom events and parameters to GA4. You can search for and enable Listeners in the library.

You’ll also need to enable Activity Features on the Listeners you want to utilize. For example, you can see here we have enabled two Activity Features inside the Hubspot Forms Listener.

Step 4: Enable Custom Values to Write Rules
Step 4: Enable Custom Values to Write Rules

Turn on the “Custom Data Layer Values” feature for the Listener you are using. Once enabled, a Custom Values menu item will appear under the Listener’s navigation, where you can write rules to define custom values in your data layer.

This powerful feature will enable even more customization of GA4 using events and parameters.

Step 5: Define Custom Data Layer Variables
Step 5: Define Custom Data Layer Variables

Create new data layer variables at the global level. These become available to push values across all of your Listeners.

Step 6: Define Custom Data Layer Variables
Step 6: Define Custom Data Layer Variables

Write rules to define values in your custom data layer variables. In the example shown here, we already have rules built to easily identify the quality of a form submission based on the email address the user submits.  This can be sent to Google Analytics 4 as a property along with a custom event.

Step 7: Preview Your Data Layer
Step 7: Preview Your Data Layer

You’ll be getting custom values and events from the data layer to power your GA4 Events & Parameters, so you’ll want to preview the data layer activity, test the behavior, and become familiar with the setup. ListenLayer will automatically push details from your applications and your custom values into the data layer.

In this example, we can see custom data layer values that ListenLayer has pushed into the data layer, and we will be using this in our GA4 events.

Step 8: Configure Your Variables inside Google Tag Manager
Step 8: Configure Your Variables inside Google Tag Manager

To use custom data layer variables inside GA4, we need to first make them available inside Google Tag Manager. To do this, create a Variable inside GTM using the Data Layer Variable type. Then copy the path to the data layer variable and paste it into the Event name.  Watch the use case video for more details on how to do this.

Step 9: Create a GA4 Event Tag Inside GTM
Step 9: Create a GA4 Event Tag Inside GTM

Now it’s time to send our events to Google Analytics 4. To do this, we’ll create a new tag and select the “Google Analytics: GA4 Event” tag template. Next, configure your event name and add any parameters you would like to send along with the event.  In this example, we will use our formQuality variable from the previous step as a parameter.

You’ll want to select a trigger for your event as well. Use a common event name from ListenLayer to focus on specific activities such as form submissions. Watch the video for more details if you are unfamiliar with this step.

Step 10: Preview Your Data Using the GA4 Debugger
Step 10: Preview Your Data Using the GA4 Debugger

Now you can publish or preview your Google Tag Manager changes and trigger your activity on your website. If you have Google Analytics 4 open in the same browser, navigate to the Debugger (as shown here), and you should see your new event appear automatically. Then, you can click on the event and begin to analyze its properties – you should see your custom property from the previous step.

Now you can make sure all of your changes are fully published and wait 24 hours for your data to settle inside of Google Analytics 4. Once settled, you will see the event and parameters being to appear.