-
Notifications
You must be signed in to change notification settings - Fork 599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug Google Analytics has stopped working #955
Comments
Same problem here |
In your
According to the Hugo documentation, the Google analytics ID should be go here:
In your Remark: In case this fixes your problem, this quirk should be fixed in the repo hugo-toha.github.io as well. |
Good morning and thank you very much for your interest. I have tried what you suggested, but the problem persists. Google Analytics is not being inserted into the page code. As a temporary solution, I have manually added the following code: <!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-GVDYVWJLRH"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-GVDYVWJLRH');
</script>
In previous versions, this or something similar was automatically added by the theme, but since the commit I mentioned, it stopped working that way, so I have temporarily resolved it by adding it manually. I have added the quotation marks as you mentioned earlier and applied the changes to match the official Hugo documentation, but it hasn't had any effect. Thank you very much, but none of this has solved the issue!! |
You are welcome.
Sorry to hear that. I checked out your site (javierasping/sentinel@0cf1c66) and was able to resolve your issue. I'm quite confident my advice given above is valid and will resolve your issue once applied correctly. Can you please download this file to the root folder of your site: Once downloaded, please delete existing file
Afterwards run Does this work for you? |
Thank you very much for responding and showing interest!!!! I tried your change with my current repository version and updated Hugo to the latest version. javiercruces@HPOMEN15:~/Documentos/sentinel$ ls -l
total 240
**-rw-r--r-- 1 javiercruces javiercruces 8138 Aug 31 20:00 _config_.yaml.txt**
-rw-r--r-- 1 javiercruces javiercruces 8055 Sep 1 22:30 hugo.yaml
javiercruces@HPOMEN15:~/Documentos/sentinel$ hugo version
hugo v0.133.1-47d00202e7e61769ce4d14691e43b27852c9cce4+extended linux/amd64 BuildDate=2024-08-26T13:58:46Z VendorInfo=gohugoio
I’m not sure if you have checked in a post that does not have the analytics script; manually verify in the HTML code that the script has not been inserted automatically. I am currently writing new posts and have tried your solution, but it did not work. I will provide you with an example of a page with the script manually added and another where the script has been removed. Hugo does not add the analytics automatically. I’m not sure if it’s because with the update the analytics work differently, but in older versions, if I searched for my tag in the HTML, I could verify that Hugo was adding it. In a class activity, I had to submit the HTML code of the generated page. You can check that in any HTML file it is included without me manually adding it in the Markdown file. I’m providing you with the link in case you want to check it: https://github.com/javierasping/CodigoHTML_sentinel/blob/main/categories/index.html. Thank you in advance for your help. If, as you mentioned, the analytics are being generated locally, please verify that the analytics script is not manually added in the post file. I always place it first, right below the title, date, and other details (I’ve been doing this since I noticed that the graph in Google Analytics was at 0). If there’s anything else I can try, please let me know. Thank you very much for your help! I’m trying to respond as quickly as possible since you’re helping me. Today, you caught me in front of the computer, so I was able to reply quickly. ;) |
It's a pity your repository is a fork that cannot be forked again. Therefore I'm unable to create a pull request that fixes your issue. What I did: I created a new own repository which starts with javierasping/sentinel@0cf1c66 and has 3 additional commits With the second commit, I added the change to config.yaml, as proposed by me: Then I regenerated the site via command For me this clearly shows that my change takes effect and effectively resolves your issue! I hope that clarifies the situation and bring you on the right track! |
I have applied the commit to my repository. Thank you so much! I ran this script to manually remove the analytics code from all the individual posts where I added it, and the analytics are now working. find . -type f -name "*.md" | while read -r fichero; do
sed -i '/<!-- Google tag (gtag.js) -->/d' "$fichero"
sed -i '/<script async src="https:\/\/www.googletagmanager.com\/gtag\/js?id=G-GVDYVWJLRH"><\/script>/d' "$fichero"
sed -i '/<script>/d' "$fichero"
sed -i '/window.dataLayer = window.dataLayer || \[\];/d' "$fichero"
sed -i '/function gtag(){dataLayer.push(arguments);}/d' "$fichero"
sed -i '/gtag('\''js'\'', new Date());/d' "$fichero"
sed -i '/gtag('\''config'\'', '\''G-GVDYVWJLRH'\'');/d' "$fichero"
sed -i '/<\/script>/d' "$fichero"
done
I credited you in the commit ;)) javierasping/sentinel@52dc44b Thanks a lot!! |
Since June 3rd, when the Git bot applied the following commit --> javierasping/sentinel@0cf1c66, my Google Analytics stats have stopped working. I have been looking into it and the script is not being inserted into the HTML code. My Google tag is G-GVDYVWJLRH.
When I search for it in the generated HTML code, I cannot find it.
My website is in www.javiercd.es .
I have tried to do as in previous cases where you helped me update to the latest version of Hugo as well as update the dependencies using the following commands:
My current version of Hugo is:
javiercruces@HPOMEN15:~/Documentos/sentinel$ hugo version hugo v0.128.1-0ff542b4b9cc7b5cb425bbab8bdb5aace81d0c03+extended linux/amd64 BuildDate=2024-07-02T06:46:41Z VendorInfo=gohugoio
Thank you very much in advance for your help, best regards!!
The text was updated successfully, but these errors were encountered: