Displaying items by tag: ga4

Sunday, 21 January 2024 19:57

How to track HubSpot Forms in GTM? Supercharged!

HubSpot stands out as a powerful CRM widely embraced in the marketing sphere. One common query that surfaces is how to effectively track HubSpot Forms using Google Tag Manager (GTM). The process is straightforward and adds a valuable tool to your GTM toolkit. We've drawn insights from Clarity Global (formerly 3WhiteHats) and Analytics Mania's Julius Fedorovicius for this technique, ensuring a robust foundation.

In our example, we go beyond the basics by extending the code to access form data, providing richer information for our marketing tags. While we specifically use GA4 Event tags in our illustration, this approach can be extended to various marketing tags like Facebook, TikTok, LinkedIn, and more. However, it's crucial to ensure compliance with organizational privacy policies and legal regulations such as GDPR or CCPA.

Implementation Steps

Step 1: Create and HTML Tag in GTM

Begin by creating an HTML tag in GTM that listens for the HubSpot FormSubmitted Event. Detailed information can be found here. The raw code below should be copied and pasted into GTM.

 <script>
  window.addEventListener("message", function(event) {
    if (event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmitted') {
      console.log(event.data);
      window.dataLayer.push({
        'event': 'hubspot-form-success',
        'hs-form-guid': event.data.id,
        'data': event.data,
      });
    } else if (event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormReady') {
      window.dataLayer.push({ 'event': 'hubspot-form-ready', 'hs-form-guid': event.data.id });
    }
  });
</script>

This code has been extended to include the submitted form data in the dataLayer, that is done by this line:

'data' : event.data

What this line does put the form data in the dataLayer.  What you will see in the dataLayer will depend on how your form has been created, in the video we will show how to review the dataLayer so that you can create your own customized Data Layer type variables.

HubSpot Form Tracking GTM Form Listener

Employ a DOM Ready Pageview trigger for the tag to ensure the complete rendering of the HubSpot form. (For extra credit you could detect a HubSpot form and only fire when one is present, but for now we will use all pages.)

Step 2: Create a Variable for the Form Data

Generate variables for the form data; for instance, 'company' in our example. The full variable name in the dataLayer is:

data.data.submissionValues.company

Adjust the final part based on your HubSpot form's variable names.  You can find them in the dataLayer formSubmission object.

HubSpot Form Tracking GTM Form Variable

Step 3: Set up a Trigger

Create a trigger to detect the 'hubspot-form-success' event defined in the listener.

HubSpotFormTrackingGTM Trigger

Step 4: Create a GA4 Event Tag

Finally, craft a GA4 Event tag using the HubSpot Form Submit trigger to send back the form variable.

HubSpotFormTrackingGTM GA4Event

With these steps, you now have a fully operational HubSpot Form tracker in GTM. Feel free to include additional form variables and channel this data to other tags. Embrace the advantages of a consistent Form Submit trigger for more accurate conversion tracking compared to traditional "thank-you" pages.

Happy Tracking! If you have any questions, whether about this or other GA4/GTM topics, let us know — we're here to help.

Referrences

 

 

Published in Blog
Sunday, 31 December 2023 22:18

GA4 IP Filters

 

How to Filter by IP Address in GA4?

A common process in keeping your GA4 data accurate is removing internal traffic.  The most common way to do that is by filtering out this traffic by IP Address.  This article will step through how to complete this process.

 

How to Define Internal Traffic using an IP Address?

The first step of this process is defining internal traffic using an IP Address.  We will use an example IP Address of 123.456.78.9 - you can find the right IP Address by typing in "What is my IP" in Google search or check with your network team to find a range of IP Addresses. 
Now navigate to the "Define internal traffic" page.  ( Admin -> Data streams -> click on Data Stream -> Configure tag settings -> click "Show more" -> Define internal traffic ) and you will see this screen:
 
 ga4 ip filtering define internal traffic
After clicking on the creat button you will see this screen:
ga4 ip filtering defininf internal traffic with an ip address 
Defining Internal Traffic by an IP Address 
Enter in a unqiue name for your "Rule name".  Notice that "traffic_type" value is defined as "internal", this is what will be used in the filter step to filter out this traffic.  You can create new "traffic_type"s at this point as well if you would like different filters, keeping in mind that there are a maximum of 10 filters allowed. 
Next select the "Match type", in this case we have selected "IP adress matches regular expression", there are other choices as well including "IP address is in range (CIDR notation)" - look here to learn more about this match type - https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing.  In the "Value" field we have coppied in our IP address and then add "\" before the "." to make it clear that we mean a period "." in our IP Address.  (The period character means a single character wildcard, using the backslash, "\", escapes the period to indicate that we mean an actual period and not a wildcard.  We will be providing a brief Regular Expression article to provide the basics that will help your GA4 analysis.  To read more - https://en.wikipedia.org/wiki/Regular_expression

How to Create a Filter in GA4?

The next step is creating (or in most cases editing) your internal traffic filter.  First navigate to Admin -> under "Data Collection and modification" click on Data filters.  From here you can Edit your "Internal Traffic" filter, or click the "Create" button to start.  You will see this:

ga4 ip filtering internal traffic filter

If the "Data filter name" is not set fill in a unique name.  Next notice that the "Parameter name" is set to "traffic_type" and the "Parameter value" is set to "internal" - in most case we can leave these alone, if you want to create additional custom filters - then the Parameter and Value will allow you to customize these settings.

Finally we will want to select the "Active" filter state - this will ensure that the traffic is permanently filtered out.  (If you only want to filter the data from reports, but want the data available, try Report Filters - here is an introduction to Exclude Filters.)  When you are complete click on the "Save" button and then click on "save filter" on the next warning that filters are destructive and irreversable.  Make sure you test your filters - to ensure no data is lost.

References:

Google Article on Filtering Internal Traffic - https://support.google.com/analytics/answer/10104470?hl=en

Google Article on Regular Expressions in Google Analytics - https://support.google.com/analytics/answer/1034324?hl=en

 
Published in Blog
Tagged under
Saturday, 22 April 2023 19:22

Edit GA4 Custom Channel Groups

Introduction:

Google Analytics 4 (GA4) is the latest version of Google Analytics that offers a more intelligent, flexible, and privacy-focused analytics solution for businesses. GA4 comes with many advanced features that provide a better understanding of user behavior, customer journey, and website performance. One such feature is the ability to edit GA4 channels, which allows you to customize your reports and insights according to your business needs.
 

What are GA4 Channels?

Channels in GA4 refer to the sources of traffic that bring visitors to your website. These channels can be categorized into various types, such as organic search, direct, social, referral, email, and paid search. Each channel has its own set of characteristics and behaviors, which can help you identify the most effective marketing channels for your business.
 

Why Edit GA4 Channels?

Editing GA4 channels can help you gain deeper insights into user behavior and optimize your marketing campaigns. By customizing your channels, you can filter out unwanted traffic sources, combine similar channels, and create new channels that better reflect your business goals. This can help you focus on the most important metrics and make better-informed decisions about your marketing strategy.
 

How to Edit GA4 Channels?

To edit GA4 channels, you need to follow these steps (also see video following this article):
Step 1: Go to the Admin section of your GA4 property and select Data Settings.
Step 2: Click on "Channel Groups".
ga4 channel group editing
 

Step 3: To start from scratch you can create a new Channel Group or more often you will 'Copy to create a new' (in some properties you may see 'duplicate') the 'Default Channel Group':

GA4 copy channel group

Step 4: In the Edit Channel Group window, you can rename the channel group, change the rules for the channels included in the group, and add or remove channels from the group.
GA4 edit or modify channels
 
Step 5: To Create a new Channel - click on the "Add new channel" button.  Then on the next screen update the criteria for this new channel.  In our example traffic with a medium of either "magazine" or "newspaper" will be assigned to our "Magazine" Channel. 
To change the rules for the channels in the group, click on the ">" button next to the channe. This will open the Channel Details window, where you can set conditions for including or excluding channels based on various parameters such as source, medium, campaign, and more.
GA4 create a new custom channel
NOTE: The regular expression in this example uses the "|" symbol which represents and "OR" - so if our medium is "magazine" or "newspaper" the Channel will be "Magazine".
Step 6: After making the necessary changes, click on "Save channel" and then "Save" to save your new channel group.
Step 7: Once you have saved your changes, the new channel group will be available in your GA4 reporting views.
 

Tips for Editing GA4 Channels:

1. Before making any changes to your channel groups, make sure you have a clear understanding of your website traffic sources and user behavior. 
2. Use descriptive names for your channel groups to make it easier to identify them in your reports.
3. Experiment with different channel group configurations to find the one that works best for your business.
4. Regularly review and update your channel groups to ensure they accurately reflect your marketing strategy and goals.

Conclusion:

Editing GA4 channels can help you gain deeper insights into user behavior and optimize your marketing campaigns. By customizing your channels, you can filter out unwanted traffic sources, combine similar channels, and create new channels that better reflect your business goals. Use the tips outlined above to make the most of your GA4 channel editing capabilities and improve your website's performance.

References:

Google Article on Channel Groups - https://support.google.com/analytics/answer/6010097?hl=en#zippy=%2Cin-this-article

Google Article on Regular Expressions in Google Analytics - https://support.google.com/analytics/answer/1034324?hl=en

 
Published in Blog