Closed j450h1 closed 3 years ago
never mind i found it
Looks like adding my tracking id to googleAnalytics:
in config.yml and then building the site didn't work. Can you confirm this is indeed a supported feature of this theme?
Yeah, it is, I can see it present in the source code of my own instance of this theme: https://github.com/seanlane/recipes/blob/6597ffada57ffb0bfdb98042d5573d36304f463e/config.yml#L6
Within the source code, the Google Analytics script is then visible at recipes.lane.sh.
thanks @seanlane. That makes sense. I must have accidentally deleted something along the way in the theme.
Still struggling with this. I have set the tracking ID in config.yml, but still no luck. Can you point me to the file that reads this parameter and generates the appropriate html?
From recipes.lane.sh, I can see that it is added immediately below the footer:
</footer>
<script type="application/javascript">
var doNotTrack = false;
if (!doNotTrack) {
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-31520487-7', 'auto');
ga('send', 'pageview');
}
</script>
</body>
</html>
Sure, the file that generates the that script is https://github.com/seanlane/gochowdown/blob/master/layouts/_default/baseof.html#L40-L42
You can see that it's a conditional statement that adds that snippet of code if the googleAnalytics
parameter in the config file is set.
When you set that parameter, is the snippet being inserted partially, but without the specified ID? Or is it not inserted at all? Also, which version of Hugo are you using to generate the site? Can you send the output of hugo version
?
> blogdown::hugo_version()
[1] ‘0.66.0’
It is not inserted at all. I went ahead and created a brand new blogdown site without any modifications and this is still the case.
I'm deploying using netlify which updates the site each time I update my github repo. Here are the logs - v0.66 is also used there: https://pastebin.com/tJtTiARF
Here is the test website I created - https://trusting-swanson-15b534.netlify.app/
Only 2 things I adjusted:
[build]
publish = "public"
command = "hugo"
[context.production.environment]
HUGO_VERSION = "0.66.0"
HUGO_ENV = "production"
HUGO_ENABLEGITINFO = "true"
[context.branch-deploy.environment]
HUGO_VERSION = "0.66.0"
[context.deploy-preview.environment]
HUGO_VERSION = "0.66.0"
I'm not sure why you're seeing those results. I opened an account to test with Netilify, and was able to get the tracking code: https://5fbdbb50b873e90007344525--goofy-mcnulty-6b476a.netlify.app/
The only thing I did (aside from fixing some minor, unrelated issues) was to add this config file: https://github.com/seanlane/recipes/blob/master/netlify.toml
The latest version of Hugo is 0.78, and that toml file uses it. Is there a reason you're specifying Hugo 0.66? Can you try with the toml file that I used (which I got from https://gohugo.io/hosting-and-deployment/hosting-on-netlify/) and see if that gives you anything different?
No particular reason why I was using v0.66. Just updated locally to latest v0.78 and added the netlify.toml file you mentioned.
No luck :( - Now I can't even see the images now: https://trusting-swanson-15b534.netlify.app
Here is the log file: https://pastebin.com/u8uwLErP
My best guess of the root cause is that:
A. The blogdown R package is doing something underneath the hood when I setup the RStudio project as per instructions here: https://github.com/rstudio/blogdown
B. There is some sort of conflict between the config files. I have three generated:
config.toml
theme = "gochowdown"
baseURL = "http://example.org/"
languageCode = "en-us"
title = "My New Hugo Site"
config.yml
baseURL: https://example.com
disablePathToLower: true
languageCode: en-us
title: My Recipes
theme: gochowdown
googleAnalytics: UA-150936119-1
defaultcontentlanguage: en
paginate: 20
canonifyurls: true
pygmentsstyle: monokai
pygmentscodefences: true
pygmentscodefencesguesssyntax: true
pygmentsOptions: "linenos=table"
permalinks:
posts: /posts/:year/:month/:title
params:
author: John Doe
description: Recipes used by the Doe family
keywords: 'recipes'
favicon_32: /images/favicon-32x32.png
favicon_16: /images/favicon-16x16.png
footercontent:
hidecredits: false
hidecopyright: false
showNavTitle: false # Boolean: show site title in nav bar
custom_css:
- style.css
menu:
main:
- name: Home
weight: 1
url: /
- name: Category
weight: 2
url: /category/
- name: Cuisine
weight: 3
url: /cuisine/
- name: Tags
weight: 4
url: /tags/
taxonomies:
category: category
cusine: cuisine
tag: tags
The third file is of course netlify.toml
[build]
publish = "public"
command = "hugo --gc --minify"
[context.production.environment]
HUGO_VERSION = "0.78.2"
HUGO_ENV = "production"
HUGO_ENABLEGITINFO = "true"
[context.split1]
command = "hugo --gc --minify --enableGitInfo"
[context.split1.environment]
HUGO_VERSION = "0.78.2"
HUGO_ENV = "production"
[context.deploy-preview]
command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"
[context.deploy-preview.environment]
HUGO_VERSION = "0.78.2"
[context.branch-deploy]
command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"
[context.branch-deploy.environment]
HUGO_VERSION = "0.78.2"
[context.next.environment]
HUGO_ENABLEGITINFO = "true"
My workflow is - I make changes in config. Enter blowdown::serve_site()
to preview the website locally as it launches a hugo server. Then finally make the commit to push changes to GitHub. Then netlify builds the site.
Thanks for your assistance so far, but I think I'm going to have to move on to a different theme. Maybe I'll give it another try in if I encounter similar issues with other themes.
Okay, some good news! I decided to give it one final try.
I have no idea why, but deleting the config.toml file and renaming config.yml to config.yaml did the job (this 2nd part was due to a blowdown error message that said it couldn't find a config.toml or config.yaml file in the RStudio project). Anyways, thanks again for helping me troubleshoot.
Interesting. Not sure why that fixed it, but glad to hear that it worked out! I'm going to close this issue since it seems resolved now, good luck with the site!
Is there a parameter to specify a Google Analytics property for tracking?