digitalcraftsman / hugo-creative-theme

Port of Startbootstrap's Creative theme to Hugo
Apache License 2.0
138 stars 116 forks source link

Add GA tracker if enabled #27

Closed ascandella closed 7 years ago

ascandella commented 7 years ago

Per the documentation: https://discuss.gohugo.io/t/implementing-google-analytics-in-hugo/2671/2

If you set a top-level googleAnalytics key, we should enable it.

This PR does that.

digitalcraftsman commented 7 years ago

Hello @sectioneight,

ascandella commented 7 years ago

Goood question. I tried the async version first but it wouldn't fire events in my testing. Since it's at a script block at the bottom of the page it shouldn't matter anyway as far as page load times. The sync version is also the code snippet that GA gives you.

Didn't realize the internal template was already checking-- I'll fix that

ascandella commented 7 years ago

PR updated to remove the extraneous if blocks. If you're not interested in this functionality that's fine, I'll just use my own fork. But it's a lovely theme (thank you for making it!) and thought others may want GA tracking.

ascandella commented 7 years ago

Awesome, thanks!