Tracking User Type at Login with Banner Detection for Salient Process

Posted by: Felix Kaboto Date Posted: January 23, 2024
Back to Case Studies

Issue

Salient Process, a leading process management and automation firm, wanted to enhance its understanding of user engagement on its platform. The primary goal was to differentiate between free and paid users immediately after login, based on the presence of a banner indicating trial period information.

The key challenge was to design a non-intrusive, privacy-respecting system that accurately classifies users without affecting the site’s performance or user experience. Additionally, the system must be robust enough to avoid duplicate event tracking within the same session or subsequent logins.

Solution

A custom JavaScript solution was implemented via Google Tag Manager (GTM) that detected the trial period banner and categorized users accordingly, firing a tracking event once per session to Google Analytics 4 (GA4). This was done without the use of user identifiers or cookies. This script achieves the following;

  1. Detects the presence of a banner with the text “Your Trial Expires in” after user login.
  2. Determine the user type based on the banner’s presence.
  3. Fire a tracking event once per session to Google Analytics 4 (GA4), capturing the user type.

For technical marketers and analytics professionals, this case study reinforces the importance of:

  • Privacy-first tracking methods in a cookieless future.
  • Leveraging session storage for single-session event tracking.
  • The power of GTM and GA4 when used in conjunction to provide actionable insights.

This solution has proven to be a low-impact yet highly effective way to gather critical user data for Salient Process. It can serve as a blueprint for similar tracking needs.

Achievement

Successfully tracked user types (free or paid) upon login for the Salient Process using banner detection, leading to better user segmentation.

Snippet/Screenshot/Link

<script>
  // Function to check if the user is free or paid
  function checkUserType() {
    var bannerText = document.querySelector('#expiryInfo'); 
    if (bannerText && bannerText.innerText.includes("Your Trial Expires in")) {
      return 'free';
    } else {
      return 'paid';
    }
  }

  // Event trigger based on user type
  var userType = checkUserType();
  var eventType = userType + '_user_login'; // Constructs the event type string

  // Since the login process triggers a page reload or navigation, 
  // we can use the session storage to ensure the event only fires once per session
  if (!sessionStorage.getItem(eventType)) {
    // Push event to GTM dataLayer
    dataLayer.push({'event': eventType});

    // Store in the session storage that we've fired this event type
    sessionStorage.setItem(eventType, 'fired');
  }
</script>