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 now has two different styles of tracking codes that require different javascript. #423

Open
mikebowler opened this issue May 29, 2021 · 6 comments

Comments

@mikebowler
Copy link

Google analytics now has two different kinds of tracking ids. The old Universal Analytics style starts with "UA-" and works properly with what's already checked in. The new Google Analytics 4 style starts with "G-" and requires the new Javascript below.

<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>

Note that I was going to submit a pull request but couldn't figure out why the analytics code was in two different places and what the interactions were. It's in both scripts.html and google-analytics.html

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity.

If this is a bug and you can still reproduce this error on the master branch, please reply with any additional information you have about it in order to keep the issue open.

If this is a feature request, please add as an Idea under discussions and elaborate on why it is core to this project and why you feel more than 80% of users would find it beneficial.

This issue will automatically be closed in 7 days if no further activity occurs. Thank you for all your contributions.

@olifre
Copy link

olifre commented Jul 30, 2021

From reading the code, I believe the google-analytics.html include is currently completely unused. It was probably meant to be used in scripts.html.
So I think a PR fixing that (including google-analytics.html in scripts.html) and then upgrading google-analytics.html would be ideal 👍 .

@mikebowler
Copy link
Author

I've submitted a PR to address this one.
#429

@channingwalton
Copy link

channingwalton commented Jul 20, 2022

Hi, any chance @mikebowler's PR could be merged?

Is there any other workaround?

@pymander
Copy link

pymander commented Oct 3, 2022

I'm also interested in seeing this get merged.

danielle-h added a commit to danielle-h/danielle-h.github.io that referenced this issue Feb 7, 2024
@danielle-h
Copy link

Thank you so much @mikebowler, I've applied this manually to my site, I couldn't figure out why my update in google-analytics.html wasn't working.

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

5 participants