Commit d8ef01c0 authored by Tyler Williams's avatar Tyler Williams Committed by Doug Stull

Update saasTrialGroup gtm event to capture trial form

parent 8ed313d2
...@@ -82,7 +82,7 @@ export const trackSaasTrialGroup = () => { ...@@ -82,7 +82,7 @@ export const trackSaasTrialGroup = () => {
return; return;
} }
const form = document.getElementById('new_group'); const form = document.querySelector('.js-saas-trial-group');
form.addEventListener('submit', () => { form.addEventListener('submit', () => {
pushEvent('saasTrialGroup'); pushEvent('saasTrialGroup');
}); });
......
import 'ee/trials/namespace_select'; import 'ee/trials/namespace_select';
import { trackSaasTrialGroup } from '~/google_tag_manager';
trackSaasTrialGroup();
...@@ -26,6 +26,7 @@ class TrialsController < ApplicationController ...@@ -26,6 +26,7 @@ class TrialsController < ApplicationController
def select def select
experiment(:trial_registration_with_reassurance, actor: current_user) experiment(:trial_registration_with_reassurance, actor: current_user)
.track(:render, label: 'trials:select', user: current_user) .track(:render, label: 'trials:select', user: current_user)
push_frontend_feature_flag(:gitlab_gtm_datalayer, type: :ops)
end end
def create_lead def create_lead
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#progress-bar #progress-bar
%h2.center= _('Create your group') %h2.center= _('Create your group')
%p= _('A group represents your organization in GitLab. Groups allow you to manage users and collaborate across multiple projects.') %p= _('A group represents your organization in GitLab. Groups allow you to manage users and collaborate across multiple projects.')
= form_for @group, url: users_sign_up_groups_path(form_params), html: { class: 'gl-show-field-errors card gl-w-full gl-p-4' } do |f| = form_for @group, url: users_sign_up_groups_path(form_params), html: { class: 'gl-show-field-errors card gl-w-full gl-p-4 js-saas-trial-group' } do |f|
= form_errors(@group) = form_errors(@group)
= render 'layouts/flash' = render 'layouts/flash'
.row .row
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
= render 'errors' = render 'errors'
= form_tag apply_trials_path(glm_params), method: :post do = form_tag apply_trials_path(glm_params), method: :post, class: 'js-saas-trial-group' do
- if show_trial_namespace_select? - if show_trial_namespace_select?
.form-group.gl-select2-html5-required-fix .form-group.gl-select2-html5-required-fix
= label_tag :namespace_id, _('This subscription is for'), for: :namespace_id, class: 'col-form-label' = label_tag :namespace_id, _('This subscription is for'), for: :namespace_id, class: 'col-form-label'
......
...@@ -87,6 +87,24 @@ RSpec.describe 'GitLab.com Google Analytics DataLayer', :js do ...@@ -87,6 +87,24 @@ RSpec.describe 'GitLab.com Google Analytics DataLayer', :js do
end end
end end
context 'on trial group select page' do
it 'tracks create group events' do
sign_in user
visit select_trials_path
evaluate_script('document.querySelector(".js-saas-trial-group").addEventListener("submit", e => e.preventDefault())')
fill_in 'new_group_name', with: group.name
find('#trial_entity_company').click
click_button 'Start your free trial'
data_layer = execute_script('return window.dataLayer')
last_event_in_data_layer = data_layer[-1]
expect(last_event_in_data_layer["event"]).to eq("saasTrialGroup")
end
end
context 'on new registration groups page' do context 'on new registration groups page' do
it 'tracks saasTrialGroup events in the dataLayer' do it 'tracks saasTrialGroup events in the dataLayer' do
sign_in user sign_in user
......
...@@ -142,7 +142,7 @@ describe('~/google_tag_manager/index', () => { ...@@ -142,7 +142,7 @@ describe('~/google_tag_manager/index', () => {
links: [{ cls: 'js-skip-trial', expectation: { event: 'saasTrialSkip' } }], links: [{ cls: 'js-skip-trial', expectation: { event: 'saasTrialSkip' } }],
}), }),
createTestCase(trackSaasTrialGroup, { createTestCase(trackSaasTrialGroup, {
forms: [{ id: 'new_group', expectation: { event: 'saasTrialGroup' } }], forms: [{ cls: 'js-saas-trial-group', expectation: { event: 'saasTrialGroup' } }],
}), }),
createTestCase(trackSaasTrialProject, { createTestCase(trackSaasTrialProject, {
forms: [{ id: 'new_project', expectation: { event: 'saasTrialProject' } }], forms: [{ id: 'new_project', expectation: { event: 'saasTrialProject' } }],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment