Disable Google Analytics tracker for dev and Google PageSpeed bot
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-04-13 10:28:42 +02:00
parent 3029c3c29f
commit 5a00c6f552
4 changed files with 50 additions and 38 deletions

View File

@@ -9,7 +9,10 @@
const { page } = stores()
// Init Google Analytics
if (typeof window !== 'undefined') {
if (typeof window !== 'undefined'
&& process.env.NODE_ENV !== 'development'
&& navigator.userAgent.indexOf('Speed Insights') == -1
) {
window.dataLayer = window.dataLayer || []
window.gtag = function gtag() {
window.dataLayer.push(arguments)
@@ -23,7 +26,10 @@
</script>
<svelte:head>
{#if process.env.NODE_ENV !== 'development'}
{#if
process.env.NODE_ENV !== 'development'
&& navigator.userAgent.indexOf('Speed Insights') == -1
}
<script async src="https://www.googletagmanager.com/gtag/js?id={id}"></script>
{/if}
</svelte:head>