Drop in GA traffic #5986
Comments
How much is the drop roughly? |
Okay, I have a bit more than one week of data now, and it looks like we are collecting 20 percentage points less metrics data than before. The block rate jumped from about 43% to 65%. That means about 65% of MDN traffic is now largely invisible to us. |
based on search traffic from search console we should be seeing a 20% y/y growth, instead we are seeing a 21% drop in users and 55% drop in page views in Google Analytics |
Here's the code on the new front-end: <script>
// Mozilla DNT Helper
/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ if(typeof Mozilla==='undefined'){var Mozilla={}}Mozilla.dntEnabled=function(dnt,ua){'use strict';var dntStatus=dnt||navigator.doNotTrack||window.doNotTrack||navigator.msDoNotTrack;var userAgent=ua||navigator.userAgent;var anomalousWinVersions=['Windows NT 6.1','Windows NT 6.2','Windows NT 6.3'];var fxMatch=userAgent.match(/Firefox\/(\d+)/);var ieRegEx=/MSIE|Trident/i;var isIE=ieRegEx.test(userAgent);var platform=userAgent.match(/Windows.+?(?=;)/g);if(isIE&&typeof Array.prototype.indexOf!=='function'){return false}else if(fxMatch&&parseInt(fxMatch[1],10)<32){dntStatus='Unspecified'}else if(isIE&&platform&&anomalousWinVersions.indexOf(platform.toString())!==-1){dntStatus='Unspecified'}else{dntStatus={'0':'Disabled','1':'Enabled'}[dntStatus]||'Unspecified'}return dntStatus==='Enabled'?true:false};
// only load GA if DNT is not enabled
if (Mozilla && !Mozilla.dntEnabled()) {
(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();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-36116321-5', 'mozilla.org');
ga('set', 'anonymizeIp', true);
// dimension1 == 'Signed-In"
ga('set', 'dimension1', 'Yes');
// dimension2 == "Beta Tester"
ga('set', 'dimension2', 'Yes');
// dimension18 == "Staff"
ga('set', 'dimension18', 'Yes');
// dimension9 == "Section editing"
ga('set', 'dimension9', 'Enabled');
(function() {
// http://cfsimplicity.com/61/removing-analytics-clutter-from-campaign-urls
var win = window;
var removeUtms = function(){
var location = win.location;
if (location.href.indexOf('utm') != -1 && win.history.replaceState) {
win.history.replaceState({}, '', location.pathname);
}
};
ga('send', 'pageview', {'hitCallback': removeUtms});
})();
}
</script> (From: view-source:https://developer.mozilla.org/en-US/) The wiki: <script>
// Mozilla DNT Helper
/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ if(typeof Mozilla==='undefined'){var Mozilla={}}Mozilla.dntEnabled=function(dnt,ua){'use strict';var dntStatus=dnt||navigator.doNotTrack||window.doNotTrack||navigator.msDoNotTrack;var userAgent=ua||navigator.userAgent;var anomalousWinVersions=['Windows NT 6.1','Windows NT 6.2','Windows NT 6.3'];var fxMatch=userAgent.match(/Firefox\/(\d+)/);var ieRegEx=/MSIE|Trident/i;var isIE=ieRegEx.test(userAgent);var platform=userAgent.match(/Windows.+?(?=;)/g);if(isIE&&typeof Array.prototype.indexOf!=='function'){return false}else if(fxMatch&&parseInt(fxMatch[1],10)<32){dntStatus='Unspecified'}else if(isIE&&platform&&anomalousWinVersions.indexOf(platform.toString())!==-1){dntStatus='Unspecified'}else{dntStatus={'0':'Disabled','1':'Enabled'}[dntStatus]||'Unspecified'}return dntStatus==='Enabled'?true:false};
// only load GA if DNT is not enabled
if (Mozilla && !Mozilla.dntEnabled()) {
(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();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-36116321-5', 'mozilla.org');
ga('set', 'anonymizeIp', true);
// dimension1 == 'Signed-In"
ga('set', 'dimension1', 'Yes');
// dimension2 == "Beta Tester"
ga('set', 'dimension2', 'Yes');
// dimension18 == "Staff"
ga('set', 'dimension18', 'Yes');
// dimension9 == "Section editing"
ga('set', 'dimension9', 'Enabled');
(function() {
// http://cfsimplicity.com/61/removing-analytics-clutter-from-campaign-urls
var win = window;
var removeUtms = function(){
var location = win.location;
if (location.href.indexOf('utm') != -1 && win.history.replaceState) {
win.history.replaceState({}, '', location.pathname);
}
};
ga('send', 'pageview', {'hitCallback': removeUtms});
})();
}
</script> (From: view-source:https://wiki.developer.mozilla.org/en-US/) No actual difference unless I fumbled when copy-n-pasting. |
What's weird is this:
That's from the new react front-end. You're never signed in! All HTML is anonymous but when we use the Here's the view-source if you use <script>
// Mozilla DNT Helper
/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ if(typeof Mozilla==='undefined'){var Mozilla={}}Mozilla.dntEnabled=function(dnt,ua){'use strict';var dntStatus=dnt||navigator.doNotTrack||window.doNotTrack||navigator.msDoNotTrack;var userAgent=ua||navigator.userAgent;var anomalousWinVersions=['Windows NT 6.1','Windows NT 6.2','Windows NT 6.3'];var fxMatch=userAgent.match(/Firefox\/(\d+)/);var ieRegEx=/MSIE|Trident/i;var isIE=ieRegEx.test(userAgent);var platform=userAgent.match(/Windows.+?(?=;)/g);if(isIE&&typeof Array.prototype.indexOf!=='function'){return false}else if(fxMatch&&parseInt(fxMatch[1],10)<32){dntStatus='Unspecified'}else if(isIE&&platform&&anomalousWinVersions.indexOf(platform.toString())!==-1){dntStatus='Unspecified'}else{dntStatus={'0':'Disabled','1':'Enabled'}[dntStatus]||'Unspecified'}return dntStatus==='Enabled'?true:false};
// only load GA if DNT is not enabled
if (Mozilla && !Mozilla.dntEnabled()) {
(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();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-36116321-5', 'mozilla.org');
ga('set', 'anonymizeIp', true);
// dimension9 == "Section editing"
(function() {
// http://cfsimplicity.com/61/removing-analytics-clutter-from-campaign-urls
var win = window;
var removeUtms = function(){
var location = win.location;
if (location.href.indexOf('utm') != -1 && win.history.replaceState) {
win.history.replaceState({}, '', location.pathname);
}
};
ga('send', 'pageview', {'hitCallback': removeUtms});
})();
}
</script> and that's definitely different! |
@escattone I think there's something strange going on with the non-wiki. I got a different HTML when I used my browser compared to Also, is the CloudFront passing through cookies and stuff for non-API urls? |
Perhaps the GA tracking works differently for anonymous vs signed in. If a signed in person visits MDN and his/her HTML gets caught in the CDN, the next person who gets that warmed up CDN cache might get HTML as if she/he was logged in. |
Set estimate to 1 for investigation. @escattone to add more issues for the fix. |
@peterbe With the new CDN configuration that I rolled-out on stage/prod with mdn/infra#291, the Here are my discoveries so far:
More to come. |
I "forked" the discussion to #6039 For the immediate future how about we focus on that |
Too many meetings today, but I had a bit of time to work on this. One thing that I'm wondering is if something changed with Firefox such that DNT is enabled by default now? That would prevent the Otherwise, I haven't see anything yet that's stands-out as something that could explain such a huge drop in |
I had checked earlier, but there was no Firefox release during that time, the drop is exactly on the day we switched to the react-front-end |
Most of our traffic is Chrome and if the latest Chrome severely broke peoples' GA stats we'd hear an uproar. :) |
I believe #6047 fixes it so that the react home page and the react document pages share the same GA code which doesn't use |
The drop in users in GA is 1/3 but the drop in pageviews is 2/3. Not sure if that's a clue actually. When we switched over to doing the
The /api/v1/whoami is notoriously slow. Roughly 0.5 seconds. Not only that but the XHR request isn't even started until after the react bundle has downloaded, parsed, executed, and lastly firing the effects. If you add that overhead with the /api/v1/whoami slowness, if any visitor is quick to close the tab or quick to click away on something else, they won't count in GA. It's still curious how this would the cause of firing almost 2/3 less pageviews. It is working after all in Chrome:And the Curiously none of this works in FirefoxNightly (Tracking Protection disabled for
|
There is an exception happening the Browser Console which MIGHT be related to this domain: @escattone Believes it's related to this: kuma/kuma/javascript/src/user-provider.jsx Line 107 in b5557a1
It's different from how the Wiki did it:
|
Ok. So ignore everything I've said about things not working in Firefox. I'd an odd unicorn who disabled Tracking Protection for Either way, sadly, Firefox being weird or not would explain the massive drop because most people are using Chrome. |
After banging my head against this all day, I'm still completely baffled why we're seeing a 60% drop in @peterbe and I have not been able to find anything yet that explains such a radical drop. When I explored this issue locally, I used the following set-up: .env file
Added the following to the
|
This is great. Thanks for digging into this @escattone and for your help too @peterbe. @atopal do you want us to continue digging in this? (it will of course, push other work out, since we originally alotted a day for this.) |
@tobinmori yes, I don't see an alternative. We're mostly flying blind at this point. |
Maybe it's helpful to know that Chrome user traffic dropped by 27% and Firefox traffic by 48% during the same time period |
Safari and Edge roughly 35%. Again, no idea if this is relevant. |
No geographic differences (except China, but that's probably due to Golden week) |
I just wanted to document what @peterbe and I just discovered and suspect is the root cause of this issue. What we've discovered is that there's a race condition in the front-end. The race is between the definition of the |
@escattone could it be because the GA |
@escattone to clarify, here it sets |
@joedarc No, it's best to leave that one async. The flaw was that we were doing this:
What it needs to be is this:
|
@peterbe Understood, makes sense. 👍 |
@joedarc @peterbe Here's my latest theory. It's a race condition between the Here's an example of what I'm seeing consistently on failure: When it works, I see that the |
The following "lazy" providence of the export default function GAProvider(props: {
children: React.Node
}): React.Node {
let ga: GAFunction;
ga = function(...args) {
// If there is a window object that defines a ga() function, then
// that ga function is the value we will provide. Otherwise we just
// provide a dummy function that does nothing.
if (typeof window === 'object' && typeof window.ga === 'function') {
window.ga(...args);
}
}
return <context.Provider value={ga}>{props.children}</context.Provider>;
} |
FWIW, i used the above code from @escattone and was unable to get the error to occur locally as well after refreshing countless times. |
That's what I have in my branch too. More or less exactly that. But I'm struggling with |
* don't depend on window.ga till it's actually needed Fixes #5986 * cleanup
Summary
We are seeing a drop in GA after the react front-end launch which is inconsistent with other data sources (search console in this case)
Steps To Reproduce (STR)
How can we ensure that we are still collecting as much telemetry as before?
The text was updated successfully, but these errors were encountered: