Analytics & Testing

How To Track Subdomains In Google Analytics 4 Accounts

By default, Google Analytics 4 (GA4) tracks all subdomains of a domain in your account, even without cross-domain tracking enabled. That’s useful if you want to aggregate all of your company’s activities throughout your subdomains in a single Google Analytics account. Martech Zone, for example, publishes translated versions of our site utilizing subdomains for each language published.

Within Google Analytics 4, I can always query or filter based on Hostname to limit my views, but that’s not always an optimal reporting solution. Companies may wish to have a Google Analytics account specific to a subdomain and do not want it included in their aggregate account.

Multiple Google Analytics 4 Accounts

There are a couple of ways to set up multiple GA4 accounts and exclude or incorporate subdomains as you’d like:

  1. Use a separate GA4 property and tag for each subdomain. This is the most straightforward approach and gives you the most control over how your data is tracked. To do this, create a new GA4 property for each subdomain you want to track separately. Once you have created the new properties, install the GA4 configuration tag on the pages of your respective subdomains. If you’d still like one account to aggregate all subdomains and another account for a specific subdomain(s), you can load multiple accounts in a single script tag.
  2. Use Google Tag Manager (GTM). GTM allows you to create more advanced control and filters than GA4. You can use GTM to trigger a tag based on the subdomain. This methodology can provide the same level of control from a script execution with many more options overall for controlling your tags. To set up a trigger to fire on a subdomain only:
    • Click Triggers > New.
    • Give your trigger a name and description.
    • Under Trigger Type, select Custom Event.
    • Under Triggering, click Add Condition.
    • Under Condition Type, select URL.
    • Under Condition Field, select Host.
    • Under Condition Value, enter the subdomain that you want the trigger to fire on. For example, if you want the trigger to fire on the subdomain blog.example.com, you would enter blog.example.com in the Condition Value field.
    • Click Save.
    • Add your tags and select the trigger(s) you created. Your tag and trigger are now added to your GTM container and will fire when a user visits the subdomain that you specified in the trigger.

Alternative: Google Analytics 4 Segments

Technically, this is NOT utilizing separate accounts but may provide you with all of the same functionality you’re seeking when wishing to compare traffic. Segments allow you to filter your data based on a variety of criteria, including hostname, user properties, and event parameters. You can create a segment for each subdomain you want to track separately. Segments don’t work across GA4 accounts but they may be a better approach than managing multiple accounts.

In GA4, navigate to Explore. You can select an exploration from the template directory that has the report data you’re looking for, then you can customize a segment to the specific subdomain.

Google Analytics 4 - Start a new exploration

Create your custom segment using Sessions.

Google Analytics 4 - Create a custom segment using sessions

Within the Explore variables, click the + on Segments to create your segment.

Google Analytics 4 - Add a segment variable

Name your segment and add a rule to specify only including sessions for that subdomain using the Hostname variable.

Google Analytics 4 - Name your segment and include subdomain as hostname

You can also build an audience using this segment (see checkbox in the top right of the previous screen). Audiences and segments in GA4 are both ways to group users, but they have different purposes and functionality.

  • Segments are used for analysis in Explorations. They can be based on any dimension, metric, or event in GA4, and they are retroactive, meaning they will show data for all users who meet the segment criteria, regardless of when they first met those criteria.
  • Audiences are used for remarketing and reporting in standard reports. They can be based on dimensions, metrics, and events, but they are not retroactive, meaning they will only start collecting data for users who meet the audience criteria after the audience is created.

In this scenario, both are solutions that can help you move forward with reporting on your subdomains.

Douglas Karr

Douglas Karr is CMO of OpenINSIGHTS and the founder of the Martech Zone. Douglas has helped dozens of successful MarTech startups, has assisted in the due diligence of over $5 bil in Martech acquisitions and investments, and continues to assist companies in implementing and automating their sales and marketing strategies. Douglas is an internationally recognized digital transformation and MarTech expert and speaker. Douglas is also a published author of a Dummie's guide and a business leadership book.

Related Articles

Back to top button
Close

Adblock Detected

Martech Zone is able to provide you this content at no cost because we monetize our site through ad revenue, affiliate links, and sponsorships. We would appreciate if you would remove your ad blocker as you view our site.