mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #3428 from overleaf/jpa-gaBlocked
[GA] do not load GA Optimize, if we observed GA being blocked previously GitOrigin-RevId: 0e3a12c0b9a086a08797c32430a567b8540d25b7
This commit is contained in:
parent
34f7c709f0
commit
e510034250
1 changed files with 20 additions and 8 deletions
|
@ -39,18 +39,30 @@ html(
|
||||||
script(type='text/javascript').
|
script(type='text/javascript').
|
||||||
ga('create', '#{gaToken}', '#{settings.cookieDomain.replace(/^\./, "")}');
|
ga('create', '#{gaToken}', '#{settings.cookieDomain.replace(/^\./, "")}');
|
||||||
ga('send', 'pageview');
|
ga('send', 'pageview');
|
||||||
|
|
||||||
|
try {
|
||||||
|
ga.isBlocked = localStorage.getItem('gaBlocked') === 'true'
|
||||||
|
if (!ga.isBlocked) {
|
||||||
|
window.addEventListener('load', function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
if (!ga.loaded) localStorage.setItem('gaBlocked', 'true')
|
||||||
|
}, 4000)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
if gaOptimize === true && typeof(gaOptimizeId) != "undefined"
|
if gaOptimize === true && typeof(gaOptimizeId) != "undefined"
|
||||||
script(type='text/javascript').
|
|
||||||
ga('require', '#{gaOptimizeId}')
|
|
||||||
ga('send', 'event', 'pageview', document.title.substring(0, 499), window.location.href.substring(0, 499))
|
|
||||||
//- Anti-flicker snippet
|
//- Anti-flicker snippet
|
||||||
style(type='text/css') .async-hide { opacity: 0 !important}
|
style(type='text/css') .async-hide { opacity: 0 !important}
|
||||||
script(type='text/javascript').
|
script(type='text/javascript').
|
||||||
(function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date;
|
if (!ga.isBlocked) {
|
||||||
h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')};
|
ga('require', '#{gaOptimizeId}');
|
||||||
(a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c;
|
ga('send', 'event', 'pageview', document.title.substring(0, 499), window.location.href.substring(0, 499));
|
||||||
})(window,document.documentElement,'async-hide','dataLayer',4000,
|
(function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date;
|
||||||
{'#{gaOptimizeId}':true});
|
h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')};
|
||||||
|
(a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c;
|
||||||
|
})(window,document.documentElement,'async-hide','dataLayer',4000,
|
||||||
|
{'#{gaOptimizeId}':true});
|
||||||
|
}
|
||||||
|
|
||||||
- else
|
- else
|
||||||
script(type='text/javascript').
|
script(type='text/javascript').
|
||||||
|
|
Loading…
Reference in a new issue