Logo
blank Skip to main content

Google Tag Manager vs Custom Click Tracker

Modern SaaS services are akin to Swiss Army knives – they can do anything. At the same time, clients only use the features of a SaaS service that they need. With time, continuous development of these services becomes very hard, as there get to be too many features to support. The need arises to define which features should be prioritized for further development. The logical way to prioritize features is to invest in the most popular, and the popularity of each feature can be determined by user behavior tracking.

Task at hand

Requirements for a user behavior tracking system include

1) flexible customization of what information is tracked;

2) a flexible filtering system

a. by tenants;

b. by users;

c. by services;

d. by user actions.

There are two ways to track user activity in SaaS applications: you can either develop a custom tracking system or you can use an existing solution. For example, you can track SaaS with using Google Tag Manager. Next, we’ll look at the pros and cons of each approach and see how a custom solution compares to a pre-built service.

Related services

Cloud Computing & Virtualization Development

Google Tag Manager as a User Activity Tracking System

Google Tag Manager (GTM) is a free tool for managing marketing activities and tracking various metrics for web-oriented products. The main features of Google Tag Manager include

1) the ability to aggregate all tags (types of data that will be tracked) in a single place;

2) the ability to implement GTM by adding only a single script to a webpage;

3)  the ability to change tracking settings without changing page code or involving developers.

How to use Google Tag Manager with SaaS:

1) Register the product that needs to be tracked on the GTM website.

2) Customize tags on the GTM website.

3) Receive scripts that need to be integrated into the tracked product in order to complete setup.

When you implement GTM into your SaaS product, your Google Analytics account will start receiving data on user actions. Google Analytics provides extensive tools to further organize and visualize this data.

Specifics of Google Tag Manager:

1) Can monitor many types of data (page opens, clicks, DOM events, form operations, etc.)

2) Can be used with iOS and Android apps in addition to websites

3) Statistics can be viewed in Google Analytics

Using Google Tag Manager to Track User Activity within SaaS Services

Configuring tracking of SaaS-specific data

Setting up analytics for SaaS involves using Google Tag Manager to configure what data will be transferred, which is done by adding some properties to the DataLayer object.

DataLayer is a regular JavaScript object that’s located on the page and contains properties that will be sent to the Google server with each tracked event.

For a SaaS service, the DataLayer object might look like this:

HTML
<script>
  dataLayer = [{
    'retailerId': 123,
    'userId': 456,
    'pagePath': 'https:⁄⁄www.draw.io⁄',
    ⁄⁄ Other properties...    
  }];
<script>

The retailerId and userId variables contain the ID of a user who performed an action on the website as well as the ID of the tenant this user is associated with. When the trigger fires, the Google Analytics server receives the whole DataLayer object, which allows it to analyze the data for each tenant separately.

Any trigger types (page opens, clicks, DOM events, form operations) can interact with the DataLayer object. For example, when the PageView trigger is activated, the DataLayer object is filled with values and sent to the Google Analytics server as soon as the page has opened.

To track user activity only on specific pages, simply place scripts for Google Tag Manager only on those pages. You can read more about script integration here.

Tracking results with Google Analytics

Using Google Tag Manager with SaaS system only allows you to configure tags and load the necessary scripts with the page for the user. Analyzing the information you collect requires configuring Google Analytics for SaaS applications.

Read also:
File System Virtualization – Part 2

Exporting data from Google Analytics

Sometimes data you collect needs to be stored on dedicated servers. The Google Analytics service allows you to download aggregated data using the Core Reporting API.

The Core Reporting API provides access to data from the majority of reports available in Google Analytics and allows you to

1) Create special summaries of Google Analytics data;

2) Automate operations with complex reports;

3) Use Google Analytics data for other business applications.

To export data you need to perform the following actions:

1) In Google Analytics settings, enable the API

2) Perform a query for Google Analytics data (see how to set query parameters and how to run queries)

To interact with existing software, Google provides a set of client libraries for various platforms including Java, JavaScript, .Net, Objective-C, and Python. You can read more about client libraries for the Core Reporting API on Google’s website.

When working with the Core Reporting API, Google limits the number of queries that can be performed per day, the number of queries that can come from a single IP, etc. You can find out more about these limitations here.

Disadvantages of Google Tag Manager

1) Data is stored on Google’s servers and thus can be viewed and used by Google.

2) This solution is fairly pricey at $150,000 per year (the free version doesn’t guarantee that more than 10 million pageviews will be processed, while the SaaS version can process a much larger number of pageviews).

3) All tracking code is located on the client side, meaning

a. tracking will not work if a user has JavaScript disabled;

b. server-side tracking, when the server receiving the request also tracks it, is impossible (server-side tracking doesn’t depend on JavaScript and has lower traffic requirements);

c. each tracked action sends data to Google’s servers, creating additional traffic.

4) Security vulnerabilities – Data on users and their relations to specific tenants of the SaaS service is usually stored in an encrypted format (for example, inside a cookie). The service itself is responsible for decrypting this data, and the decryption happens on the server side. With GTM, since data is sent to a third-party service (Google Analytics), you need to store the data in an unencrypted format to allow filtering by users and tenants.

5) GTM is designed to improve marketing metrics such as number of pageviews from third-party websites, time spent on each page, etc. Such metrics are usually irrelevant for SaaS services, as these services usually have different goals. The most important thing for SaaS services is to provide the best user experience. Therefore, a lot of GTM capabilities aren’t useful for SaaS services.

Custom User Activity Tracking System

The main advantage of developing a custom user activity tracking system is that you can account for all necessary cases at an early design stage. For example, you can implement server-side tracking, which is more secure than Google Tag Manager as it doesn’t require you to send unencrypted user and tenant data to third-party servers.

Read also:
Building SaaS CRM systems: brief overview

A custom user activity tracking solution should include the following components:

1) A database containing tables with tracked data;

2) A separate service for recording data to the database;

3) A domain model with code that allows you to call the service and transfer data on a specific event to it;

4) A domain model call to a specific method of a corresponding controller to implement tracking of specific actions;

5) A Click Tracker Controller – a new controller that gathers requests from pages that don’t call SaaS service controllers via built-in JavaScript code (examples of such pages include pages that lead to separate websites or pages processed with other software);

6) A JavaScript module built into a webpage that will send AJAX requests to the Click Tracker Controller in order for the controller to work.

Event tracker controller diagram

For an EventTracker to work, you need the following tables in your database:

tPageHitEventLog table – serves as a log of information about pages that were opened, when they were opened, and who opened them

tEventModule table – used for storing names of tracked modules of the product

tEventModuleUrl table – contains corresponding tracked paths for each module

Database tables diagram


 

The WCF service is a separate service for filling the above-mentioned tables with data. The WCF service receives data from the domain model of a SaaS service. The only contract that the service provides is the TrackPageHit method that accepts a PageHitEvent as a parameter.

C++
 [DataContract]
public class PageHitEvent 
{
    [DataMember]
    public string DbName { get; set; }
    [DataMember]
    public int UserId { get; set; }
    [DataMember]
    public string IpAddress { get; set; }
    [DataMember]
    public DateTime EventDate { get; set; } 
    [DataMember]
    public string PagePath { get; set; }
    [DataMember]
    public int? EventModuleId { get; set; }
}

Next, we should add the code that calls the domain model when the controller is called. This code will also transfer data that needs to be recorded into the domain model.

Advantages and Disadvantages of a Custom Solution

Google Tag Manager has a number of disadvantages that can be solved with a custom click tracker. A custom click tracker offers the following advantages:

1) Data is stored only on the server of the tracking service and is available only to personnel who develop and maintain the service.

2) There’s no need to store user or tenant data in an unencrypted form. Cookie encryption is performed on the server, as is tracking. This solution is more secure than GTM.

3) Only necessary tracking features are implemented, designed specifically to fit the SaaS service being monitored.

4) You can use server-side tracking (JavaScript is not required on the target endpoint), which means lower traffic requirements overall.

5) Nothing prevents JavaScript from being employed in instances where server-side tracking cannot be used (for example, as part of the SaaS service implemented on specific hardware or some legacy technology).

The cost of setting up Google Tag Manager and integrating it in a SaaS service is lower than the cost of developing a new solution from scratch. However, after Google Tag Manager is implemented you still need to pay a subscription fee of $150,000 a year.

At the same time, implementing a custom tracking solution includes paying for development and data storage, the requirements for which are constantly increasing. However, there will most likely be no need to increase server capacity, since you need only one lightweight server to receive data and write it to the database. The technologies used to implement a custom tracker are free, and the necessary software and operating system are already employed by the used. The price of development can also be reduced if you have an in-house development team available or are using an experienced subcontractor.

When To Choose a Custom Solution

1) When the subscription price for Google Tag Manager is too high.

2) When tracked data contains sensitive information that shouldn’t be made available to third parties such as Google.

3) When security requirements don’t allow for storing user/tenant data in an unencrypted format.

4) When you don’t plan to use Google Analytics to track marketing data in the future.

Tell us about your project

Send us a request for proposal! We’ll get back to you with details and estimations.

By clicking Send you give consent to processing your data

Book an Exploratory Call

Do not have any specific task for us in mind but our skills seem interesting?

Get a quick Apriorit intro to better understand our team capabilities.

Book time slot

Contact us