Skip to content
This repository has been archived by the owner on Jul 8, 2021. It is now read-only.

Commit

Permalink
Switch to Hugo's own googleAnalytics config option
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalcraftsman committed Mar 22, 2016
1 parent 747bae1 commit fa10c8e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
7 changes: 2 additions & 5 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ title = "Material Docs"
theme = "hugo-material-docs"
metadataformat = "yaml"
canonifyurls = true
# Enable Google Analytics by entering your tracking id
googleAnalytics = ""

[params]
# General information
Expand All @@ -21,11 +23,6 @@ canonifyurls = true

permalink = "#"

# Google Analytics
#
# Add your tracking code as first value followed by a comma
google_analytics = ["auto"]

# Custom assets
custom_css = []
custom_js = []
Expand Down
4 changes: 1 addition & 3 deletions exampleSite/content/getting-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ Favicons are small small icons that are displayed in the tabs right next to the
You can enable Google Analytics by replacing `UA-XXXXXXXX-X` with your own tracking code.

```toml
[params]
# Google Analytics
google_analytics = ["UA-XXXXXXXX-X", "auto"]
googleAnalytics = "UA-XXXXXXXX-X"
```

### Small tweaks
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/footer_js.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
}
</script>

{{ if eq (len .Site.Params.google_analytics) 2 }}
{{ with .Site.GoogleAnalytics }}
<script>
(function(i,s,o,g,r,a,m){
i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||
Expand All @@ -59,7 +59,7 @@
})(window, document,
'script', '//www.google-analytics.com/analytics.js', 'ga');
/* General initialization */
ga('create', '{{ index .Site.Params.google_analytics 0 }}', '{{ index .Site.Params.google_analytics 1 }}');
ga('create', '{{ . }}', 'auto');
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');
/* Track outbound links */
Expand Down

0 comments on commit fa10c8e

Please sign in to comment.