From 58d5dae75d9f57b11abd719d850ec6a468e8b3b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Romain?= Date: Wed, 14 Sep 2016 02:12:00 +0200 Subject: [PATCH] Remove dependency on jQuery Fix an error if jQuery is not available in the global window. --- views/js/GoogleAnalyticActionLib.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/views/js/GoogleAnalyticActionLib.js b/views/js/GoogleAnalyticActionLib.js index 72062aa..9c9cf98 100755 --- a/views/js/GoogleAnalyticActionLib.js +++ b/views/js/GoogleAnalyticActionLib.js @@ -121,20 +121,22 @@ var GoogleAnalyticEnhancedECommerce = { }, addProductClick: function(Product) { - var ClickPoint = jQuery('a[href$="' + Product.url + '"].quick-view'); + var ClickPoint = document.querySelector('a[href$="' + Product.url + '"].quick-view'); - ClickPoint.on("click", function() { - GoogleAnalyticEnhancedECommerce.add(Product); - ga('ec:setAction', 'click', { - list: Product.list - }); - - ga('send', 'event', 'Product Quick View', 'click', Product.list, { - 'hitCallback': function() { - return !ga.loaded; - } + if (ClickPoint && ClickPoint.length > 0) { + ClickPoint.addEventListener('click', function() { + GoogleAnalyticEnhancedECommerce.add(Product); + ga('ec:setAction', 'click', { + list: Product.list + }); + + ga('send', 'event', 'Product Quick View', 'click', Product.list, { + 'hitCallback': function() { + return !ga.loaded; + } + }); }); - }); + } },