From 149d08fbae7a0c747e816fb47752581486c27677 Mon Sep 17 00:00:00 2001 From: Bhargav Mehta Date: Sun, 7 Jan 2018 13:10:18 +0530 Subject: [PATCH 1/2] Fix 12221 --- .../GoogleAnalytics/view/frontend/web/js/google-analytics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/GoogleAnalytics/view/frontend/web/js/google-analytics.js b/app/code/Magento/GoogleAnalytics/view/frontend/web/js/google-analytics.js index 324881cdc5028..4f6f3e9ae88a0 100644 --- a/app/code/Magento/GoogleAnalytics/view/frontend/web/js/google-analytics.js +++ b/app/code/Magento/GoogleAnalytics/view/frontend/web/js/google-analytics.js @@ -54,7 +54,7 @@ define([ ga('send', 'pageview' + config.pageTrackingData.optPageUrl); // Process orders data - if (config.ordersTrackingData) { + if (config.ordersTrackingData.length) { ga('require', 'ec', 'ec.js'); //Set currency code From e851948a93f63887f053559802b6de1348db4a56 Mon Sep 17 00:00:00 2001 From: Bhargav Mehta Date: Mon, 8 Jan 2018 17:26:35 +0530 Subject: [PATCH 2/2] Updated code to make it more efficient. --- .../GoogleAnalytics/view/frontend/web/js/google-analytics.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/GoogleAnalytics/view/frontend/web/js/google-analytics.js b/app/code/Magento/GoogleAnalytics/view/frontend/web/js/google-analytics.js index 4f6f3e9ae88a0..cd6292b39e989 100644 --- a/app/code/Magento/GoogleAnalytics/view/frontend/web/js/google-analytics.js +++ b/app/code/Magento/GoogleAnalytics/view/frontend/web/js/google-analytics.js @@ -51,7 +51,6 @@ define([ if (config.pageTrackingData.isAnonymizedIpActive) { ga('set', 'anonymizeIp', true); } - ga('send', 'pageview' + config.pageTrackingData.optPageUrl); // Process orders data if (config.ordersTrackingData.length) { @@ -75,6 +74,9 @@ define([ } ga('send', 'pageview'); + }else{ + // Process Data if not orders + ga('send', 'pageview' + config.pageTrackingData.optPageUrl); } } }