From fee9c203f4cf28698d5bf8367cc5dacff34dbb18 Mon Sep 17 00:00:00 2001 From: Teppo Jalava Date: Tue, 22 Aug 2017 00:19:45 +0300 Subject: [PATCH] Simplify Google Analytics code, #70 --- src/api/ga.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/api/ga.js b/src/api/ga.js index 4a16405..9c7f98c 100644 --- a/src/api/ga.js +++ b/src/api/ga.js @@ -14,11 +14,7 @@ })(window, document, "script", "https://www.google-analytics.com/analytics.js", "ga"); let gaTrackingId = sizeme_options.gaTrackingId; - -let gaEnabled = false; -ga(function () { - gaEnabled = gaTrackingId !== null; -}); +let gaEnabled = gaTrackingId !== null; let trackEvent = (action, label) => { if (gaEnabled) { @@ -32,6 +28,8 @@ let trackEvent = (action, label) => { }); }; trackEvent(action, label); + } else { + trackEvent = () => {}; } };