Published on 2025-06-26T04:25:51Z

What is Subdomain Tracking? Examples with GA4 and Plainsignal

Subdomain Tracking ensures that user interactions across multiple subdomains of a single site are treated as part of the same session and user journey. When a website uses subdomains like blog.example.com, shop.example.com, or support.example.com, default analytics setups may mistakenly count visits to each subdomain as distinct sessions or refer traffic from one subdomain to another. By configuring your analytics property to recognize a common parent domain, subdomain tracking unifies these sessions under one umbrella, providing accurate metrics on user behavior and attribution. Google Analytics 4 (GA4) provides built-in support for subdomain tracking, often requiring only minimal configuration to set the cookie domain to ‘auto’. Plainsignal, a cookie-free analytics solution, automatically captures data across subdomains when you specify the correct domain in its script snippet, as shown below. Proper subdomain tracking is vital for getting a holistic view of your website’s performance and avoiding data fragmentation. Without it, marketers risk misinterpreting user flows and making decisions based on incomplete data.

Illustration of Subdomain tracking
Illustration of Subdomain tracking

Subdomain tracking

Method to unify analytics across multiple subdomains, ensuring seamless user sessions and accurate cross-subdomain attribution.

Why Subdomain Tracking Matters

Subdomain tracking ensures accurate and continuous measurement of user behavior across all parts of your site. Without it, analytics systems treat each subdomain as a separate entity, leading to broken sessions, inflated metrics, and misleading attribution data. Below are key reasons to implement subdomain tracking:

  • Unified user sessions

    Keeps user sessions intact as they navigate between subdomains, providing a single, continuous journey.

    • Session preservation:

      Prevents new sessions from starting when users move between subdomains.

    • Accurate engagement metrics:

      Avoids inflated session and user counts by treating all interactions as part of one journey.

  • Consistent referral attribution

    Maintains original traffic source information when users traverse subdomains.

    • Referral exclusion:

      Blocks internal subdomain traffic from appearing as referrals, preventing self-referrals.

    • True source tracking:

      Ensures marketers see the genuine origin of user visits, not subdomain handoffs.

Implementing Subdomain Tracking in GA4

GA4 simplifies subdomain tracking by using a single measurement ID and setting cookies at the root domain. Below are steps to configure GA4 for seamless cross-subdomain analytics:

  • Gtag.js configuration

    Customize the tracking snippet to set the cookie_domain parameter to 'auto', enabling cookies at the highest level.

    • Code snippet:
      gtag('config', 'G-XXXXXXXXXX', {
        cookie_domain: 'auto'
      });
      
  • Google tag manager setup

    If using Google Tag Manager, ensure your GA4 tag’s Fields to Set includes cookie_domain set to auto and that the trigger fires on all subdomains.

    • Fields to set:

      Add a field named cookie_domain with value auto in the tag configuration.

    • Trigger configuration:

      Use All Pages trigger so the tag loads on every subdomain.

Implementing Subdomain Tracking in Plainsignal

PlainSignal operates without cookies and can track across subdomains by specifying your base domain in the script’s data-do attribute. Follow these instructions to deploy PlainSignal on all your subdomains:

  • Basic integration

    Include the PlainSignal script on each subdomain with your domain and ID. Example:

    • Script snippet:
      <link rel="preconnect" href="//eu.plainsignal.com/" crossorigin />
      <script defer data-do="yourwebsitedomain.com" data-id="0GQV1xmtzQQ" data-api="//eu.plainsignal.com" src="//cdn.plainsignal.com/PlainSignal-min.js"></script>
      
  • Advanced configuration

    Adjust the data-id for your workspace, set a custom data-api endpoint, and ensure CORS settings allow cross-subdomain requests.

    • Custom api endpoint:

      Modify data-api to point to your regional PlainSignal server if needed.

    • Cross-origin headers:

      Ensure your server responds with appropriate CORS headers for PlainSignal’s requests.

Common Challenges and Best Practices

Even with proper setup, issues can arise. Here are best practices and tips to ensure reliable subdomain tracking:

  • Avoiding self-referrals

    Exclude your domain from referral lists and confirm your analytics property treats subdomains as same domain.

    • Ga4 referral exclusion:

      Add example.com under Admin > Data Streams > More Tagging Settings > List Unwanted Referrals.

  • Testing and validation

    Regularly verify tracking across subdomains using analytics debugging tools.

    • Ga4 debugview:

      Use GA4’s DebugView to watch events in real time as you navigate each subdomain.

    • Plainsignal debug mode:

      Append ?ps_debug=1 to your URL and check the developer console for PlainSignal logs.


Related terms