How to Track User Interactions in GA4 for a B2B Site

Will Rice
First published February 16th, 2023
Last updated May 6th, 2024
Stay ahead of the game with Fred Pike's expert insights on tracking user interactions in GA4 for B2B sites, shared at GA4ward.
How to Track User Interactions in GA4 for a B2B Site

This is a write-up of Fred Pike’s great talk at GA4ward on tracking user interactions in GA4. You can find his slides here. You can also find a recording of his talk here.


Working with GA4 is a lot like renovating a room in your house. You’re probably asking ‘how?’. Well, inside your house, you have walls, windows, and ceilings. You’re protected from the elements. That’s similar to what a basic Google Analytics 4 implementation gives you. In other words, you’re tracking page views, file downloads, and search terms.

But to really make use of GA4, you need to build out from that implementation. This involves a similar process to renovation. You take all the tools and construction materials and personalize your environment to suit your own needs.

But where does this process begin? Let’s focus on three different areas for tracking user interactions using Google Analytics 4 for a B2B site:

  • What to track
  • How to track it
  • What to call it

All the examples we’re talking about today revolve around Google Tag Manager (GTM). If you haven’t already, make sure you’re clued up with GTM.


What to track

When working on a home construction project, you’ll have a number of things you’ll need to track. This might involve removing a chimney or woodburning stove. Similarly, there are lots of essential areas to consider when carrying out user tracking in GA4. These areas can be grouped into a broad category: meaningful user interactions.

Of course, this term can mean many different things and will vary from website to website. However, there are some interactions that most websites have in common. Let’s focus on four common meaningful user interactions that you might want to track.

Calls to Action (CTAs) – CTAs are a common feature for many different websites. But are they effective? If you don’t track them, you won’t know. That’s why CTAs are one of the first things that you should be tracking when working on a new website.

Shares – Is your blog content being shared on social media?

Search terms – Are you capturing important search terms?

Forms – If you have forms on your website, you’ll want to check if people are filling them out.

User-blocks – What is blocking a user from being effective on your website?


How to track it

Here are some popular options for user tracking in GA4.

CSS/HTML – This option is for when you have no access to the backend of a website. Instead, you have to look at the CSS or HTML elements available to you on individual pages.

Custom classes and data attributesThis choice is available when you do have access to the backend of a website. You can add some custom CSS classes and data attributes.

dataLayer pushes – Let’s imagine, you’re working with a developer and they are sending information into the dataLayer. GTM can make use of this information (we’ll talk more about this later).


The Tools

To carry out any Google Analytics B2B tracking, you’ll need certain tools. These include

Developer console –  This tool delivers valuable information for users (even if you have little prior knowledge).

GTM/GA debugger (from David Vallejo / – Downloading this tool puts a useful structure around what’s happening within the developer console.


GA4 Events

Before we dive further into user tracking in GA4, we need to look at GA4 events. As you probably know, everything in GA4 is an event. Every event has an event_name (e.g. “form_submitted”). Each event also has up to 25 associated parameters to describe it.


No Access

Let’s look at the first of the three popular user tracking options mentioned earlier. In this scenario, you have no access to the backend of a website. We are relying solely on the elements of a webpage (the CSS and HTML).


CTA for a IrishFest event


Let’s consider the CTA in the image above from the IrishFest event.


backend code for a button


By inspecting the ‘Learn More’ button, we can see that it is classed as a ‘span.Button’. Without knowing much about the site, we can feel pretty certain that each CTA will be a ‘span.Button’.

Now, let’s go into the Analytics debugger, and click the ‘Learn More’ button.


analytics debugger interface


You’ll notice that the debugger is split into three different sections. These are ‘GTM/GTAG’, ‘GA3’, and ‘GA4’. If we go into GA4, we see an event called ‘Click’.


events in GA4 from analytics debugger interface


From the debugger, we can now dig a little deeper into our event. In the image above, you’ll see a list of parameters associated with the click event. We can see useful information, such as the time that an event was triggered, and the destination of the link.

With this information, we can identify the forces driving user interactions. Is it paid or organic traffic, does traffic come from email? Later down the line we can analyze these interactions and improve our CTAs.


What’s happening in GTM?

trigger configuration option in gtm

At this point, you might wonder ‘what is actually happening in GTM when an event is triggered?’. The first thing to notice is that we have a trigger that looks at the click element (the area of the page that was clicked). This matches the CSS Selector of span.button. In other words, whenever we click a button classed as span.button, the trigger will fire.

tag configuration options for google analytics: GA4 event


Alongside that, our GA4 event with the click_type of CTA will also fire.

As you can see, this is quite simple to set up. Even without access to the backend, we have a lot of power over what we can track.


Access to the backend

Now let’s look at user tracking in GA4 when we do have access to the backend. With access, you can go into the HTML code and make changes yourself.

Here, we’ll be looking at ‘faux-CSS’. This has nothing to do with the areas that CSS normally controls, such as color. It simply exists for GTM to grab.



This time, we’ll look at the webpage of Novus Mortgage. We’ll inspect the ‘Get Started’ button.


window after inspecting the elements of a button


Again, we have a span class of button. But we also have a faux CSS class labelled ‘class= “CTA”’. This means nothing to the CSS, and exists purely for GTM. Within the faux CSS class, we also have ‘data-clicktype= “CTA”’. This identifies the click as a CTA.


Now, let’s scroll down the page a little to the ‘5-step loan process’ and select the first option.



Again, we can see the faux CSS class. But this time the data-clicktype is ‘Digital Loan Process’. Because we have access to the backend, we can differentiate and see that not all clicks are CTAs. We gained much more thorough information than we did on the IrishFest site.


click types that are being captured on a particular site


Above, we can see some of the click types that are being captured on the Novus website. Because we have access to the backend, we can refine the user tracking in GA4.


What’s happening in GTM?

Again, let’s look at what’s happening in the background in GTM.


variable configuration interface in gtm


The click type element has been captured as a data layer variable in GTM. Here we named the dataset ‘data-clicktype’. Of course, you can choose whichever name is most appropriate for your dataset. All CTAs will be captured within this variable, this includes the digital loan process we looked at earlier.

But once captured what happens next?


trigger configuration interface in GTM


We have a trigger that fires when an element is clicked that contains the faux CSS class.


tag configuration interface in GTM


Next, we go into the GA4 event itself. Here is where things are slightly different from IrishFest. You might remember that in IrishFest, the click_type was hard coded to CTA. Here we’re pulling that variable and inserting it as a data click type. 



The end result is that we get this information in GA4.

So, we’ve gained a lot of insight without having deep developer skills. With access to the backend, we can do a great deal in GA4 to track user interactions. We can even break these interactions down into individual categories for more detailed information.


dataLayer push

The dataLayer is a place where different applications can send data. GTM will listen for occurrences within the dataLayer and respond to them. It’s a way of transferring information between different applications.


datalayer push example on a contact us page


In the above example, we’re looking at a contact us page. We wanted to look at how people were contacting team members. The event, through dataLayer push is ‘Contact a Team Member’. We can also see the name of the member that was contacted, the method of contact (in this instance, email), and the page that a user goes to.

But once you’ve gained this information about user interaction, what can you do with it? Let’s look at an example from Coveo Search. This is a powerful search application for websites.



As you can see above, we have searched for CRM on the Salesforce website using Coveo Search. By looking at the URL, you can see that the query parameter is ‘#q’. Unfortunately, GA4’s standard search implementation doesn’t recognize this parameter. This search won’t show up within GA4 reports. Instead, we need a different way of capturing the search terms. 

So, what has Salesforce done to get around this barrier? The answer is by using a dataLayer push. 


how salesforce have datalayer push for their benefits


Let’s search again, and this time look at the Analytics Debugger. The second result ‘custEv_siteSearch’ is our dataLayer. In the second panel, we can see ‘eventAct: “crm analytics”: our search query. Coveo is carrying out a dataLayer push and sending important information (our search term).


What’s happening in GA4?



The end result of this process is that GA4 receives a search event. If we scroll far enough down the event parameters, we can find our search term.


Is this a good idea?

Whenever you add a new piece of content or a new feature to your site, you might ask a question. Is this ‘is this a good idea?’. Will new additions help or hinder users? How will people react to changes? By measuring meaningful user interactions in GA4, you can gain an answer to this question.

Let’s look at an example of using Google Analytics for a B2B site of a client.



When a user arrives on the client’s site they are played a video. Whilst the video is playing, the user is unable to select any other elements on the page. The only way to gain control is by clicking the cross at the top right.


session recording for watching a video


Looking at session recordings, we found it wasn’t long before people were clicking the cross. In fact, within five seconds over 50% of people had exited the video.

By measuring meaningful user interactions, it’s pretty clear that people aren’t sticking around. If anything, the video is more of an annoyance to customers.



Forms are an extremely important element on a website. But how do you go about tracking them? Well, we have a few different options.

  • We could use the ‘Submit‘ button. But this isn’t advised, after all, people don’t always fill out forms correctly. You generate a lot of false positives using this method.
  • We could track the ‘Thank You’ page. This is a better method but not perfect. A user could refresh the page, meaning they are counted twice.
  • We could use a dataLayer push. This is the best method, measuring the point that a form has been filled out correctly.

This is a topic that could have a whole article dedicated to it. For a more detailed rundown of form tracking in GA4, view this article.


What to call it

When user tracking with Google Analytics B2B, what will you name your events? Let’s start by looking at form-tracking events.


Google's recommended events for online sales tracking


Google gives us a variety of options. The closest choice for form filling would be generate_lead.


Detailed info for the generate_lead event


But the parameters associated with this event are ‘currency’ and ‘Value’. These don’t exactly correlate with form tracking. More useful information would be ‘which form did a user fill out?’ or ‘Which page were they on?’. This information is missing here.


Event Types

GA4 has four different event types:

  • Automatic
  • Enhanced Measurement
  • Recommended
  • Custom*

*Despite what you may have been told by Google, custom events are your friend. But when you start to create custom events, remember some of these key factors: 

  • Be descriptive – Choose a name that makes sense to you. For example, you might use ‘CTA’ rather than ‘Button’. Just remember, don’t go over 40 characters or your event will be truncated.
  • snake_case – When choosing parameter and event names always use lowercase with an underscore for a space (e.g. form_submitted instead of Form Submitted). Doing so will make it easier for you to find events and parameters in GA4.
  • An unlimited number of events – But don’t go crazy. You aren’t likely to have more than 20 or 25 meaningful interactions to track.


Event Parameters

There are several things to remember about event parameters when using GA4 for a B2B site. Perhaps the biggest of these is that there are limits. Unlike events, you can only create 50 parameters. For this reason, use existing parameters as much as possible.

If you follow this link you can find a list of parameters that are available to you.


custom definitions interface


Remember too, that if you want to create custom parameters, you need to register them. Go to the configure section>Custom definitions, and then register your parameter.


Don’t be tempted

You may have a set of event category actions and labels from your GA3 setup. But don’t be tempted to replicate this in GA4. The GA4 model is much richer than in Universal Analytics. Take the time to think about the events and parameters that you want to track. Remember, you have up to 25 parameters to describe an event. Make use of them.

Let’s go back to the analogy that we started with. At the end of this process is your renovation project complete? Well, not quite. A lot of the work has been done, but a website is not a static thing, neither are user interactions.  Instead, continue to monitor your analytics data and website, and add tracking.

By constantly carrying out user tracking in GA4, you’ll create the best experiences for your users.


Further reading

Want more? Check out our blog for tips on Google Analytics, as well as a whole host of other Google packages.


About Fred Pike

Fred is the GA/GTM Practice Lead at Northwoods. He is also a community expert in both DataDrivenU (Jeffalytics) & MeasureSchool.

He has created three video courses on Google Analytics for CXL Institute.


Will Rice
Follow me
0 0 votes
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Articles from our Blog
Would love your thoughts, please comment.x