From 4a2016a9e39460a6b1c342cd0367bad575465a15 Mon Sep 17 00:00:00 2001 From: Tamme Schichler Date: Fri, 14 Jan 2022 12:01:22 +0100 Subject: [PATCH] Don't include Google Analytics scripts without analytics id (#482) --- _config.yml | 4 ++-- _includes/head.html | 3 ++- _includes/js-selector.html | 2 +- assets/js/data/swcache.js | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/_config.yml b/_config.yml index e3bc6be..4feeee0 100644 --- a/_config.yml +++ b/_config.yml @@ -49,13 +49,13 @@ social: # - https://www.facebook.com/username # - https://www.linkedin.com/in/username -google_site_verification: google_meta_tag_verification # change to your verification string +google_site_verification: # fill in to your verification string # ↑ -------------------------- google_analytics: - id: '' # fill in your Google Analytics ID + id: # fill in your Google Analytics ID # Google Analytics pageviews report settings pv: proxy_endpoint: # fill in the Google Analytics superProxy endpoint of Google App Engine diff --git a/_includes/head.html b/_includes/head.html index 710d47d..eac902b 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -40,7 +40,8 @@ - {% if jekyll.environment == 'production' %} + {% if jekyll.environment == 'production' + and site.google_analytics.id != empty and site.google_analytics.id %} diff --git a/_includes/js-selector.html b/_includes/js-selector.html index 219fe96..2e73f60 100644 --- a/_includes/js-selector.html +++ b/_includes/js-selector.html @@ -61,7 +61,7 @@ - {% if site.google_analytics.id %} + {% if site.google_analytics.id != empty and site.google_analytics.id %} {% include google-analytics.html %} {% endif %} diff --git a/assets/js/data/swcache.js b/assets/js/data/swcache.js index ec648a0..4017f74 100644 --- a/assets/js/data/swcache.js +++ b/assets/js/data/swcache.js @@ -43,7 +43,7 @@ const resource = [ /* The request url with below domain will be cached */ const allowedDomains = [ - {% if site.google_analytics.id != '' %} + {% if site.google_analytics.id != empty and site.google_analytics.id %} 'www.googletagmanager.com', 'www.google-analytics.com', {% endif %}