Google Tag Manager

LearningBuilder does not have a “1st class” Tag Manager integration, but Tag Manager can be easily integrated using existing configuration features.

As of Jul 1, 2023 GTM is only officially supported if you disable Google Analytics in AppConfig (e.g. setting EnableGoogleAnalytics to “false”). See below.

Overview

Google Tag Manager (GTM) is a platform for adding multiple types of engagement tracking “tags” to a website without needing to manually code them on the website itself. Essentially, a single block of code is added to every page in the site, and then all of the individual trackers and “tags” are managed externally through the Google Tag Manager site itself.

A common use case for integrating Tag Manager into LearningBuilder is to correlate in-app credentialing events to the marketing campaigns that led to those events.

For a detailed example, see

Using Google Analytics in conjunction with Tag Manager

If you wish to enable GTM as described below, you should disable the EnableGoogleAnalytics feature toggle.

This will prevent analytics data for the instance from being aggregated in the main Heuristic Solutions account and may hamper our ability to monitor and proactively respond to high traffic events.

When this document was originally written, LearningBuilder was using the legacy ga.js script to implement Google Analytics. That script worked side-by-side with GTM.

On July 1, 2023, Google retired support for the legacy Google Analytics script. LearningBuilder was updated to use the new gtag.js script to implement Analytics.

However, Google’s official advice is that only one of those two methods (gtag.js and Tag Manager) be used at the same time:

Important: You should only use one of the two methods, not both. Using both methods will have unintended consequences, such as overcounting data from your website.

Therefore, to comply with the official Google advice, and until GTM is implemented as a 1st class feature, you should disable the built-in Google Analytics tracking if you wish to implement Tag Manager.

This will prevent traffic statistics from being tracked in the Heuristics monitoring system.

What if I want to use Tag Manager and capture analytics?

The recommended way is to implement Analytics as a “tag” within the Tag Manager UI itself:

  • Disable Google Analytics in LearningBuilder

  • Implement Tag Manager (per below), using the client’s Tag Manager account;

  • Using Tag Manager, add an Analytics Tag configured with the Heuristic Solutions property ID.

The exact configuration steps are outside the scope of this document and are not covered by any support warranties.

What will happen if I run gtag.js and Tag Manager side-by-side?

It depends on many factors. The safe answer is “don’t do that, it’s not officially supported”, but at the time of this writing they appear to work fine together.

This configuration is unlikely to have a negative effect on LearningBuilder itself, but it could disrupt, corrupt, or over-count analytics data, per the Google statement above. We have not done any work to prove/disprove that assertion.

Production issues stemming from the use of Tag Manager while EnableGoogleAnalytics is “true” will be covered as paid support.

Configuring LearningBuilder to use Tag Manager

Setting up a Tag Manager account

Step

Step

1

Create a Google Tag Manager account

Create a free account at Google Tag Manager

2

Publish the workspace

Configuring the specific Tags and Triggers is outside the scope of this document. Regardless of what configuration steps you take, you will need to publish your changes to make them live before LearningBuilder will be able to integrate with the account.

LearningBuilder configuration

Step

Step

1

Get the Tag Manager initialization code from GTM

Log into GTM and locate the block of JavaScript code that initializes Tag Manager.

How to find the init code from the Tag Manager site
2

Add the init code to the global JavaScript block in App Config

In LearningBuilder, go to Sys Admin → App Configuration and search for the GlobalJavascriptBlock setting. Add the script block to desired Scope.

This code should be identical for all GTM installations, except for the client ID, so if you’re having trouble try using this instead, replacing “GTM-XXXXXX” with the actual client ID.

// Google Tag Manager (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-XXXXXX'); // end Google Tag Manager
3

Determine which environments to enable it for

Testing the configuration

There is no way, within LearningBuilder itself, to know if things are set up correctly. You’ll need to log into the GTM system to determine if event data is flowing over.

The best you can do from LearningBuilder is check for JavaScript errors on the page after adding the script.

Step

Step

1

Take a baseline

Before adding the App Config script, go to the LearningBuilder login page and check for errors.

If you’ve already added the App Config script, temporarily disable it by setting an environment-specific override.

To check for errors in Microsoft Edge / Chrome:

  1. Click the “…” menu in the toolbar

  2. Choose More Tools → Developer Tools

  3. Select the “Console” tab

  4. Go to (or refresh) the Login page of your LearningBuilder instance

  5. Make a note of any errors you see

 

2

Enable the script

Re-enable the GTM script after taking the baseline error check

3

Check for errors again

Repeat step #1, refreshing the page with the GTM script enabled.

If you see new errors in the console, then the script probably wasn’t added correctly.

If you do not see any new errors, then the script is working correctly. Any additional testing will need to be done on the GTM side.