adding netlify env variables for google analytics
parent
1cf0eaa8ed
commit
15458d13aa
3
Gemfile
3
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
|
||||||
|
|
|
@ -25,4 +25,4 @@ Serif is a beautiful small business theme for Jekyll. It contains content types
|
||||||
|
|
||||||
To run the theme locally, navigate to the theme directory and run `bundle install` to install the dependencies, then run `jekyll serve` or `bundle exec jekyll serve` to start the Jekyll server.
|
To run the theme locally, navigate to the theme directory and run `bundle install` to install the dependencies, then run `jekyll serve` or `bundle exec jekyll serve` to start the Jekyll server.
|
||||||
|
|
||||||
I would recommend checking the [Deployment Methods](https://jekyllrb.com/docs/deployment-methods/) page on Jekyll website.
|
I would recommend checking the [Deployment Methods](https://jekyllrb.com/docs/deployment-methods/) page on Jekyll website.
|
||||||
|
|
|
@ -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>
|
{% assign gid = site.env.NETLIFY_GOOGLE_ANALYTICS_ID %}
|
||||||
<script>
|
{{ gid }}
|
||||||
window.dataLayer = window.dataLayer || [];
|
|
||||||
function gtag(){dataLayer.push(arguments);}
|
{% if gid %}
|
||||||
gtag('js', new Date());
|
<script async src="https://www.googletagmanager.com/gtag/js?id={{ gid }}"></script>
|
||||||
|
<script>
|
||||||
gtag('config', '{{ site.google_analytics_id }}');
|
window.dataLayer = window.dataLayer || [];
|
||||||
</script>
|
|
||||||
|
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