Don't include Google Analytics scripts without analytics id (#482)

This commit is contained in:
Tamme Schichler 2022-01-14 12:01:22 +01:00 committed by Cotes Chung
parent a6c73e8f4f
commit 4a2016a9e3
4 changed files with 6 additions and 5 deletions

View file

@ -49,13 +49,13 @@ social:
# - https://www.facebook.com/username # - https://www.facebook.com/username
# - https://www.linkedin.com/in/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: google_analytics:
id: '' # fill in your Google Analytics ID id: # fill in your Google Analytics ID
# Google Analytics pageviews report settings # Google Analytics pageviews report settings
pv: pv:
proxy_endpoint: # fill in the Google Analytics superProxy endpoint of Google App Engine proxy_endpoint: # fill in the Google Analytics superProxy endpoint of Google App Engine

View file

@ -40,7 +40,8 @@
<link rel="dns-prefetch" href="https://fonts.gstatic.com"> <link rel="dns-prefetch" href="https://fonts.gstatic.com">
<!-- GA --> <!-- GA -->
{% if jekyll.environment == 'production' %} {% if jekyll.environment == 'production'
and site.google_analytics.id != empty and site.google_analytics.id %}
<link rel="preconnect" href="https://www.google-analytics.com" crossorigin="use-credentials"> <link rel="preconnect" href="https://www.google-analytics.com" crossorigin="use-credentials">
<link rel="dns-prefetch" href="https://www.google-analytics.com"> <link rel="dns-prefetch" href="https://www.google-analytics.com">

View file

@ -61,7 +61,7 @@
<script defer src="{{ '/app.js' | relative_url }}"></script> <script defer src="{{ '/app.js' | relative_url }}"></script>
<!-- GA --> <!-- GA -->
{% if site.google_analytics.id %} {% if site.google_analytics.id != empty and site.google_analytics.id %}
{% include google-analytics.html %} {% include google-analytics.html %}
{% endif %} {% endif %}

View file

@ -43,7 +43,7 @@ const resource = [
/* The request url with below domain will be cached */ /* The request url with below domain will be cached */
const allowedDomains = [ const allowedDomains = [
{% if site.google_analytics.id != '' %} {% if site.google_analytics.id != empty and site.google_analytics.id %}
'www.googletagmanager.com', 'www.googletagmanager.com',
'www.google-analytics.com', 'www.google-analytics.com',
{% endif %} {% endif %}