Skip to content

Commit

Permalink
add google analytics option
Browse files Browse the repository at this point in the history
  • Loading branch information
joergbrech committed Feb 26, 2019
1 parent b9a3f19 commit cb00101
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
8 changes: 7 additions & 1 deletion jupyter_book/book_template/_config.yml
Expand Up @@ -79,6 +79,12 @@ download_button_text : "Download" # The text that download buttons w
# Bibliography and citation settings. See https://github.com/inukshuk/jekyll-scholar#configuration for options
scholar:
style: apa

#######################################################################################
# Option to add a Goggle analytics tracking code

google_analytics:
mytrackingcode:


#######################################################################################
Expand Down Expand Up @@ -138,4 +144,4 @@ plugins:
- jekyll-scholar

# Jupyter Book version - DO NOT CHANGE THIS. It is generated when a new book is created
jupyter_book_version: INSERT
jupyter_book_version: INSERT
11 changes: 11 additions & 0 deletions jupyter_book/book_template/_includes/analytics.html
@@ -0,0 +1,11 @@
{% if site.google_analytics.mytrackingcode %}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics.mytrackingcode }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{{ site.google_analytics.mytrackingcode }}');
</script>
{% endif %}
1 change: 1 addition & 0 deletions jupyter_book/book_template/_layouts/default.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<html lang="en">
{% include analytics.html %}
{% include head.html %}
<body>
<!-- .js-show-sidebar shows sidebar by default -->
Expand Down

0 comments on commit cb00101

Please sign in to comment.