adding netlify env variables for google analytics
parent
1cf0eaa8ed
commit
15458d13aa
1
Gemfile
1
Gemfile
|
@ -1,2 +1,3 @@
|
||||||
source "https://rubygems.org"
|
source "https://rubygems.org"
|
||||||
gem 'github-pages'
|
gem 'github-pages'
|
||||||
|
gem 'jekyll-environment-variables'
|
|
@ -114,6 +114,8 @@ GEM
|
||||||
rouge (~> 2)
|
rouge (~> 2)
|
||||||
jekyll-default-layout (0.1.4)
|
jekyll-default-layout (0.1.4)
|
||||||
jekyll (~> 3.0)
|
jekyll (~> 3.0)
|
||||||
|
jekyll-environment-variables (1.0.0)
|
||||||
|
jekyll (~> 3.0)
|
||||||
jekyll-feed (0.11.0)
|
jekyll-feed (0.11.0)
|
||||||
jekyll (~> 3.3)
|
jekyll (~> 3.3)
|
||||||
jekyll-gist (1.5.0)
|
jekyll-gist (1.5.0)
|
||||||
|
@ -243,6 +245,7 @@ PLATFORMS
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
github-pages
|
github-pages
|
||||||
|
jekyll-environment-variables
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.17.1
|
1.17.1
|
||||||
|
|
|
@ -1,11 +1,31 @@
|
||||||
{% if site.google_analytics_id %}
|
{% if jekyll.environment == "production" %}
|
||||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
|
||||||
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics_id }}"></script>
|
|
||||||
<script>
|
|
||||||
window.dataLayer = window.dataLayer || [];
|
|
||||||
function gtag(){dataLayer.push(arguments);}
|
|
||||||
gtag('js', new Date());
|
|
||||||
|
|
||||||
gtag('config', '{{ site.google_analytics_id }}');
|
{% assign gid = site.env.NETLIFY_GOOGLE_ANALYTICS_ID %}
|
||||||
</script>
|
{{ gid }}
|
||||||
|
|
||||||
|
{% if gid %}
|
||||||
|
<script async src="https://www.googletagmanager.com/gtag/js?id={{ gid }}"></script>
|
||||||
|
<script>
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
|
||||||
|
function gtag() {
|
||||||
|
dataLayer.push(arguments);
|
||||||
|
}
|
||||||
|
gtag('js', new Date());
|
||||||
|
gtag('config', '{{ $gid }}');
|
||||||
|
</script>
|
||||||
|
{% else %}
|
||||||
|
{% if site.google_analytics_id %}
|
||||||
|
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics_id }}"></script>
|
||||||
|
<script>
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
|
||||||
|
function gtag() {
|
||||||
|
dataLayer.push(arguments);
|
||||||
|
}
|
||||||
|
gtag('js', new Date());
|
||||||
|
gtag('config', '{{ site.google_analytics_id }}');
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
Loading…
Reference in New Issue