Browse Source

Add Google Analytics option

Fixes #3
master
digitalcraftsman 9 years ago
parent
commit
22c8662eb4
  1. 2
      exampleSite/config.toml
  2. 10
      layouts/partials/js.html

2
exampleSite/config.toml

@ -12,6 +12,8 @@ theme = "hugo-cactus-theme"
twitter = "Your Twitter account"
# Disable comments by leaving disqusShortname empty
disqusShortname = "spf13"
# Enter your tracking code to enable Google Analytics
googleAnalytics = ""
enableRSS = true
# The variables below are optionally too and can be used to

10
layouts/partials/js.html

@ -2,3 +2,13 @@
<script src="{{ .Site.BaseURL }}js/main.js"></script>
<script src="{{ .Site.BaseURL }}js/highlight.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
{{ with .Site.Params.googleAnalytics }}
{{ "<!-- Google Analytics -->" | safeHTML }}
<script>
var _gaq=[['_setAccount','{{ . }}'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>
{{ end }}
Loading…
Cancel
Save