Closed digitalcraftsman closed 8 years ago
Dumb question - but where exactly is this documented? I've been looking for a while now and can't find it.
Site variables (https://gohugo.io/templates/variables/), mentions .Site.GoogleAnalytics and says this:
"A string representing your tracking code for Google Analytics as defined in the site configuration."
Ok, so I go to configuration (https://gohugo.io/overview/configuration/) but I see nothing there.
Hello @cfjedimaster,
I've integrated this feature shortly before the release of Hugo v0.15. But this didn't included the documentation. Since a while I'm waiting for feedback to add it.
However, you can enable the internal Google Analytics template by adding the following line to your theme:
{{ template "_internal/google_analytics.html" . }}
Now, move to the config file and assign your tracking code to the corresponding variable:
googleAnalytics = ""
The template behaves similar to the one of Disqus. If googleAnalytics
is not set or equals an empty string the internal template will not appear in your generated sites.
Thanks. Should the bug be reopened though?
Which bug do you mean?
Well, it says, "I've recognized that the docs are missing an example of the built-in Google Analytics template.", and I guess I saw this as related, but maybe a new bug should be filed for the variable?
Now, I understand what you mean. I've updated the first comment and mentioned the config variable explicitly.
but maybe a new bug should be filed for the variable
Both things are closely related. Therefore, I would keep them together in a single issue.
Cool, and thank you for the help.
On Fri, Jan 15, 2016 at 3:17 PM, digitalcraftsman notifications@github.com wrote:
Now, I understand. I've updated the first comment and mentioned the config variable explicitly.
but maybe a new bug should be filed for the variable
Both things are closely related. Therefore, I would keep them together in a single issue.
— Reply to this email directly or view it on GitHub https://github.com/spf13/hugo/issues/1654#issuecomment-172094733.
Raymond Camden, Developer Advocate for MobileFirst at IBM
Email : raymondcamden@gmail.com Blog : www.raymondcamden.com Twitter: raymondcamden
I added pull request #1829, does this satisfy the documentation requirement?
Hello @dherbst,
your commit seems to be fine. A new page in the extras-section is reasonable. I would have written the docs myself but I didn't got feedback about a location so far.
I would merge your commit if nobody has something to complain. @bep, @anthonyfok: do you agree?
Looks good to me, @digitalcraftsman! Just make sure you change "Adds" to "Add" in the commit message. <grin, duck, run>
Newcomer to hugo here, and I'm not able to get this working with the existing documentation. Is it out of date?
For those that stumble on this, I was helped by this example footer.html, where you just replace the literal UA value with {{ .Site.GoogleAnalytics }}
, after you've set googleAnalytics = "UA-0000000-00"
in your config.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
I've recognized that the docs are missing an example of the built-in Google Analytics template and of the corresponding variable for the config file.
What would be a good place to insert them into the docs? Furthermore, the docs provide an example of a footer partial taken from the code of spf13.com.
Should I remove the GA part of this example?
/cc @anthonyfok @bep