From f72775a262df456a39e3e4613bfce21ce85065b0 Mon Sep 17 00:00:00 2001 From: Alex Gibson Date: Mon, 5 Feb 2024 09:47:51 +0000 Subject: [PATCH] Fix JS error in GA4 event tracking (Fixes #14177) --- media/js/base/datalayer-productdownload.es6.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/media/js/base/datalayer-productdownload.es6.js b/media/js/base/datalayer-productdownload.es6.js index 8bd6d1647a9..db60f6c88aa 100644 --- a/media/js/base/datalayer-productdownload.es6.js +++ b/media/js/base/datalayer-productdownload.es6.js @@ -226,8 +226,11 @@ TrackProductDownload.handleLink = (event) => { TrackProductDownload.sendEventFromURL = (downloadURL) => { // get event object const eventObject = TrackProductDownload.getEventFromUrl(downloadURL); - // send for tracking - TrackProductDownload.sendEvent(eventObject); + + if (eventObject) { + // only send event for tracking if eventObject is valid (issue 14177) + TrackProductDownload.sendEvent(eventObject); + } }; /**