Skip to content

Google Analytics API Double Tracking Error #14522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
erichagz opened this issue Apr 3, 2018 · 8 comments
Closed

Google Analytics API Double Tracking Error #14522

erichagz opened this issue Apr 3, 2018 · 8 comments
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@erichagz
Copy link

erichagz commented Apr 3, 2018

Preconditions

  1. AWS EC2 C4-Large, Ubuntu 16.04.4 LTS, PHP 7.0.28-0ubuntu0.16.04.1
  2. Magento 2.2.2
  3. Also using AWS Redis for page caching. Following directions on https://devdocs.magento.com/guides/v2.2/config-guide/redis/redis-pg-cache.html
  4. innodb_version | 5.7.21| protocol_version | 10

Steps to reproduce

  1. Sales >> Google API >> Enabled >> Add Tracking Code >> Anonymous IP NO >> Enable Content Experiments NO
  2. Check the Google Tag
  3. Check Analytics Account

Expected result

  1. Expect working properly, it is tracking, but with errors.

Actual result

  1. Same web property ID is tracked twice error in Google Tag
  2. Bounce Rate doesn't read
  3. Wacky tracking products that I can't read in analytics: Custom\u0020Foam\u0020Board\u0020Signs\u002024\u0022x36\u0022

Was using this API instead of the direct tracking code so that I can track e-commerce numbers. It is tracking the amounts properly.

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Apr 3, 2018
@king-themes
Copy link

The same with 2.2.3

@sfdevrv
Copy link

sfdevrv commented Apr 16, 2018

Same here too with 2.2.3

@peterjaap
Copy link
Contributor

Same here on 2.2.3

@peterjaap
Copy link
Contributor

@erichagz have you already found the culprit for this bug?

@J-Fricke
Copy link

Any further info on this? Our marketing team has just pointed this issue has shown up since we deployed v2.2.2

@erichagz
Copy link
Author

@peterjaap I have not figured it out. Talking to Google they had said it was definitely Magento and they wouldn't count the mis-represented bounce rate against me.

@peterjaap
Copy link
Contributor

peterjaap commented May 22, 2018

We found it and made a composer patch for it.

Here's the fix;

From c7d049fb548d5bc8d982340686d2deacfa0d1bab Mon Sep 17 00:00:00 2001
From: peterjaap <[email protected]>
Date: Tue, 8 May 2018 16:44:19 +0200
Subject: [PATCH 1/1] Fix GA triggered twice - see
 https://github.com/magento/magento2/issues/12221

Signed-off-by: peterjaap <[email protected]>
---
 view/frontend/web/js/google-analytics.js | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/view/frontend/web/js/google-analytics.js b/view/frontend/web/js/google-analytics.js
index 324881c..5a5da03 100644
--- a/view/frontend/web/js/google-analytics.js
+++ b/view/frontend/web/js/google-analytics.js
@@ -36,8 +36,8 @@ define([
             (function (i, s, o, g, r, a, m) {
                 i.GoogleAnalyticsObject = r;
                 i[r] = i[r] || function () {
-                        (i[r].q = i[r].q || []).push(arguments)
-                    }, i[r].l = 1 * new Date();
+                    (i[r].q = i[r].q || []).push(arguments)
+                }, i[r].l = 1 * new Date();
                 a = s.createElement(o),
                     m = s.getElementsByTagName(o)[0];
                 a.async = 1;
@@ -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) {
@@ -75,7 +74,10 @@ define([
                 }

                 ga('send', 'pageview');
+            }else{
+                // Process Data if not orders
+                ga('send', 'pageview' + config.pageTrackingData.optPageUrl);
             }
         }
     }
-});
+});
\ No newline at end of file
--
2.17.0


(the first set of -'s and +'s is just indenting which my editor did automatically, sorry)

The solution was eventually found buried deep in this thread; #12221

We've been using this fix on several stores in the last week and all bounce rates are fine and Google Tag Assistant does not complain about double tracking codes anymore.

Also, this fix is needed to keep tracking the conversions; #12221 (comment)

@ghost ghost self-assigned this Aug 29, 2018
@ghost ghost added Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Aug 29, 2018
@ghost
Copy link

ghost commented Aug 29, 2018

Hi @erichagz thank you for you report, the fix for this issue already available in 2.2.6 release

@ghost ghost added Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line labels Aug 29, 2018
@ghost ghost closed this as completed Aug 29, 2018
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests

6 participants