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

Adding GA4-Google Analytics to the site #613

Closed
tirtharajdash opened this issue Mar 25, 2022 · 2 comments · Fixed by #727
Closed

Adding GA4-Google Analytics to the site #613

tirtharajdash opened this issue Mar 25, 2022 · 2 comments · Fixed by #727
Assignees

Comments

@tirtharajdash
Copy link
Contributor

tirtharajdash commented Mar 25, 2022

Google recently launched GA4 analytics. While the present al-folio version supports Google analytics, a simple change in analytics.html activates GA4 analytics too.

In the _config.yml file, add the following line at a convenient place:

ga4_analytics: G-XXXXXXXXXX #This is your GA4 measurement ID

Now, go to _includes/scripts/analytics.html and add the following (maybe just below the current gtag.js:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.ga4_analytics }}"></script>
  <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', '{{ site.ga4_analytics }}');
  </script>

Then, commit and push. Done.

@rohandebsarkar
Copy link
Collaborator

Seems like GA4 analytics use the same scripts as previous Google Analytics. In that case, I don't think we need to make any more changes. Just adding a note in the _config.yml and probably changing the ID to G-XXXXXXXXXX will make thing clear.

Please reach out if I am missing anything.

@rohandebsarkar
Copy link
Collaborator

Created PR #727.

It would be helpful if you or someone else could verify, this is working or not. And probably give any suggestions if needed.

@rohandebsarkar rohandebsarkar linked a pull request Jun 28, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants