Google Analytics
Hi there,
I followed the instructions to use google analytics, and GA does not see any connection to the website, any view, etc.
Could you tell me if the publisehd process is not valid anymore ?
Thanks
Update
For others landing here. There are two open PRs for this (1 each for the 2.5-stable and master branch) below. Either copy changes as per PR diff or use the remote-theme plugin to pull in patch from applicable PR branch:
- #824 — for
v2.5series - #825 — for the unreleased
v3
I checked the Analytics dashboard for manual installation instructions for Google Analytics. It provided me with a snippet to include in my site. I compared it to _includes/google-analytics.html included in this repo and it did not match. I replaced this file by creating a file called google-analytics in my local directory _includes with the snippet that was provided to me, which is at time of writing:
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ site.google_analytics }}');
</script>
This caused data to start flowing into my Google Analytics instance. If you need to troubleshoot, further check out this documentation: https://support.google.com/tagassistant/answer/10039345?sjid=15349293314530816036-EU.
@iTiamo Will you be able to submit a pull request to update the analytics code provided by Minima?
A previous version of my comment included my own Google Analytics tag, I hadn't replaced it with the right liquid parameter. I have done so now.
@ashmaroli Sure, I will do so. https://github.com/jekyll/minima/pull/824
site.google_analytics : analytics ID should be added to config.yml right ?
Yes, this is already detailed in the README.
https://github.com/jekyll/minima/tree/2.5-stable?tab=readme-ov-file#enabling-google-analytics
Yes indeed sorry. Still not working. Maybe a "production"environment variable issue on github. Analytics is only working in production mode according to the README This is a bit of an annoying struggle.
Thanks for the help btw
Yes, I had to include the environment variable in my GitHub pages deployment. Additionally the Google Analytics tag should be in the root of the config file. Note that the site object is populated from there. So don't create a site object in the config file yourself.
For others landing here. There are two open PRs for this (1 each for the 2.5-stable and master branch) below. Either copy changes as per PR diff or use the remote-theme plugin to pull in patch from applicable PR branch:
- #824 — for
v2.5series - #825 — for the unreleased
v3
How do you include it ? From what I got, I thought github was automatically putting the environment variable to production by default.
If you are using GH pages, you can find the environment variables in your repository's settings, environments, github-pages. You can validate the Google Analytics deployment by inspecting your blog's HTML code. Simply CTRL+F for the Google Analytics tag. I hope that helps.
to be honest, there is a problem that readme description of how to add G analytics to config is quite vague, I've made a PR to fix that https://github.com/jekyll/minima/pull/853 more than a week ago, nothing happened for now
when I did it like I've described, stats started flowing to Google Analytics just fine fyi
From #656, I understand there's no expected release date for v3. If so, is there a chance to release a v2.5.3 with this fix?...
The fix for this (#824) merged to 2.5-stable branch is the only commit difference from v2.5.2:
Note that I bumped into this issue when using github-pages, which uses v2.5.1 (https://github.com/github/pages-gem/blob/cd7369a21e3ec3f20753012da8e312859dca41a4/lib/github-pages/plugins.rb#L51), and I would prefer to request a change on their side to pin to a new gem version rather than to a git branch or ref.