Skip to content

Commit

Permalink
Add Google Analytics Support (yousinix#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
rribeiro1 authored Jun 14, 2020
1 parent 42edeb0 commit 9c3f1aa
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions _includes/analytics.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{%- if jekyll.environment == 'production' and site.analytics.enabled == true -%}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.analytics.google.tracking_id }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{{ site.analytics.google.tracking_id }}');
</script>
{%- endif -%}
1 change: 1 addition & 0 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</main>

{% include footer.html %}
{% include analytics.html %}
{% include scripts.html %}

</body>
Expand Down
7 changes: 7 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ collections:
disqus: your-short-name-disqus # Your website Shortname on disqus


### Analytics ###
analytics:
enabled: false # Set true to enable analytics
google:
tracking_id: your-google-tracking-id


### Defaults for collections ###
defaults:
- scope:
Expand Down
7 changes: 7 additions & 0 deletions test/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ collections:
output: true


### Analytics ###
analytics:
enabled: true
google:
tracking_id: google-tracking-id


### Defaults for collections ###
defaults:
- scope:
Expand Down

0 comments on commit 9c3f1aa

Please sign in to comment.