Skip to content

Update GTM to capture trial form saasTrialGroup event

What does this MR do and why?

This MR resolves the first item in gitlab-com/marketing/digital-experience/buyer-experience#259 (closed).

It updates the trackSaasTrialGroup Google Tag Manager function to track saasTrialGroup events with the js-saas-trial-group selector, which allows us to track these events across https://gitlab.com/-/trials/select and https://gitlab.com/users/sign_up/groups/new

This is part of a broader effort to instrument GitLab with Google Tag Manager, tracked in gitlab-com/marketing/digital-experience&43 (closed).

How to set up and validate locally

  1. Create a Google Tag Manager account and container ID. You should just need to follow the step 1 of the instructions. The GTM container can be empty - it just needs to exist.
  2. Enable the relevant feature flags
    Feature.enable(:ecomm_instrumentation)
    Feature.enable(:gtm_nonce)
    Feature.enable(:gitlab_gtm_datalayer)
  3. In gitlab.yml, add your GTM ID in the extra block for both the google_tag_manager_id and google_tag_manager_nonce_id values. Make sure to restart GDK (or do this step prior to starting GDK) for settings to take effect.
    extra:
     google_tag_manager_id: 'GTM-YOURIDHERE'
     google_tag_manager_nonce_id: 'GTM-YOURIDHERE'
  4. Open the Google Tag Assistant and point it to http://localhost:3000/-/trial_registrations/new
  5. Walk through the trial flow until you get to /-/trials/select
  6. Create a group or use an existing group for your user
  7. Click "start your free trial" and check that the Google Tag Assistant registers the saasTrialGroup in the dataLayer

I also added a feature spec and Jest spec to verify the behavior.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Tyler Williams

Merge request reports