Skip to content

Commit

Permalink
Added Google Analytics integration
Browse files Browse the repository at this point in the history
  • Loading branch information
schoenenberg committed Aug 6, 2020
1 parent 01ebb85 commit b6c30fb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ taxonomies = [
# Put all your custom variables here
links = [
]
google_analytics = { enabled = true, id = "UA-174641029-2"}
9 changes: 9 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
<!-- Feeds -->
{% if config.generate_feed %}<link rel="alternate" type={% if config.feed_filename == "atom.xml" %}"application/atom+xml"{% else %}"application/rss+xml"{% endif %} title="RSS" href="{{ get_url(path=config.feed_filename) | safe }}">{% endif %}

<!-- Google Analytics -->
{% if config.extra.google_analytics.enabled %}<script async src="https://www.googletagmanager.com/gtag/js?id={{ config.extra.google_analytics.id }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ config.extra.google_analytics.id }}');
</script>{% endif %}

<script>
function setTheme() {
const time = new Date();
Expand Down
1 change: 1 addition & 0 deletions theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ title = "Zola-Paper"
# Use snake_casing to be consistent with the rest of Zola
[extra]
links = []
google_analytics = { enabled = false, id = ""}

# The theme author info: you!
[author]
Expand Down

0 comments on commit b6c30fb

Please sign in to comment.