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

[FEATURE/FIX] Move from analytics.js to gtag.js (Google Analitics V4) #63

Closed
davorpa opened this issue Oct 31, 2020 · 2 comments · May be fixed by #134
Closed

[FEATURE/FIX] Move from analytics.js to gtag.js (Google Analitics V4) #63

davorpa opened this issue Oct 31, 2020 · 2 comments · May be fixed by #134

Comments

@davorpa
Copy link

davorpa commented Oct 31, 2020

Hi

A new version of Google Analitics has released, V4, and scripting block has changed.

Documentation Guide: https://developers.google.com/analytics/devguides/collection/gtagjs/migration

It will be a good point to change this lines for new ones provided by guide.

{% if site.google_analytics %}
<script>
(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','//www.google-analytics.com/analytics.js','ga');
ga('create', '{{ site.google_analytics }}', 'auto');
ga('send', 'pageview');
</script>
{% endif %}

Of course, mantaining backwards compatibility using some site property indicating the mode to load.

Are you agree?

@davorpa davorpa changed the title [FEATURE/FIX] Move to Google Analitics V4 [FEATURE/FIX] Move fron analytics.js to gtag.js (Google Analitics V4) Nov 3, 2020
@davorpa
Copy link
Author

davorpa commented Nov 3, 2020

At least in other themes was updated. For example, in caiman:

https://github.com/pages-themes/cayman/blob/1bcabf8e4c139d46ebe0678998059db53f670caf/_layouts/default.html#L5-L13

@davorpa davorpa changed the title [FEATURE/FIX] Move fron analytics.js to gtag.js (Google Analitics V4) [FEATURE/FIX] Move from analytics.js to gtag.js (Google Analitics V4) Nov 3, 2020
@davorpa
Copy link
Author

davorpa commented Jul 27, 2021

Modularized at #79

@davorpa davorpa closed this as completed Jul 27, 2021
bovlb added a commit to bovlb/frc-tips that referenced this issue Feb 14, 2023
bovlb added a commit to bovlb/hacker that referenced this issue Feb 14, 2023
This should work with both old Universal Analytics (UA) and new Google Analytics v4 (GA4).

Resolves pages-themes#63
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

Successfully merging a pull request may close this issue.

1 participant