Skip to content
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

Google Analytics #816

Open
fattaccioli opened this issue Oct 29, 2024 · 11 comments
Open

Google Analytics #816

fattaccioli opened this issue Oct 29, 2024 · 11 comments

Comments

@fattaccioli
Copy link

fattaccioli commented Oct 29, 2024

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:

@iTiamo
Copy link

iTiamo commented Nov 25, 2024

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.

@ashmaroli
Copy link
Member

@iTiamo Will you be able to submit a pull request to update the analytics code provided by Minima?

@iTiamo
Copy link

iTiamo commented Nov 25, 2024

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. #824

@fattaccioli
Copy link
Author

site.google_analytics : analytics ID should be added to config.yml right ?

@iTiamo
Copy link

iTiamo commented Nov 25, 2024

@fattaccioli
Copy link
Author

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.

@fattaccioli
Copy link
Author

Thanks for the help btw

@iTiamo
Copy link

iTiamo commented Nov 25, 2024

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.

@ashmaroli
Copy link
Member

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:

@fattaccioli
Copy link
Author

How do you include it ?
From what I got, I thought github was automatically putting the environment variable to production by default.

@iTiamo
Copy link

iTiamo commented Nov 25, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants