From 2494af078211d841a5bec1c0cb10399bc5e56859 Mon Sep 17 00:00:00 2001 From: Andy Sellick Date: Thu, 11 Nov 2021 16:34:41 +0000 Subject: [PATCH] Restore check for window.ga - this was unintentionally removed in a recent change --- .../javascripts/modules/set-ga-client-id-on-form.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/modules/set-ga-client-id-on-form.js b/app/assets/javascripts/modules/set-ga-client-id-on-form.js index 250777bb7..7c15f4d4e 100644 --- a/app/assets/javascripts/modules/set-ga-client-id-on-form.js +++ b/app/assets/javascripts/modules/set-ga-client-id-on-form.js @@ -8,11 +8,14 @@ window.GOVUK.Modules = window.GOVUK.Modules || {}; SetGaClientIdOnForm.prototype.init = function () { var form = this.$module - window.ga(function (tracker) { - var clientId = tracker.get('clientId') - var action = form.getAttribute('action') - form.setAttribute('action', action + '?_ga=' + clientId) - }) + + if (window.ga) { + window.ga(function (tracker) { + var clientId = tracker.get('clientId') + var action = form.getAttribute('action') + form.setAttribute('action', action + '?_ga=' + clientId) + }) + } } Modules.SetGaClientIdOnForm = SetGaClientIdOnForm