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

why template google_analytics_async not support google v4? #8549

Closed
xiantang opened this issue May 20, 2021 · 8 comments
Closed

why template google_analytics_async not support google v4? #8549

xiantang opened this issue May 20, 2021 · 8 comments

Comments

@xiantang
Copy link

my using theme is use google_analytics_async template. i want add google analytics to my blog, but it not work.
https://github.com/gohugoio/hugo/blob/3d5dbdcb1a11b059fc2f93ed6fadb9009bf72673/tpl/tplimpl/embedded/templates/google_analytics_async.html
i find the result is the google_analytics_async not support v4 code..

#8287

@gwuah
Copy link

gwuah commented Jan 23, 2022

@chalin
Copy link
Contributor

chalin commented Jul 5, 2022

GA4 support is now available (though via _internal/google_analytics.html). For details, see https://gohugo.io/templates/internal/#use-the-google-analytics-template.

It seems that this issue can be closed.

@jmooring
Copy link
Member

jmooring commented Apr 8, 2023

Addressed by #8287

@jmooring jmooring closed this as completed Apr 8, 2023
@kirillbobyrev
Copy link
Contributor

kirillbobyrev commented Apr 16, 2023

@jmooring why does that patch address this issue? IIUC author is asking for Google Analytics 4 support in _async version, not the regular one. Unless I am mistaken, linked PR does not deal with loading GA4 asynchronously.

@jmooring jmooring reopened this Apr 16, 2023
@jmooring
Copy link
Member

@kirillbobyrev I've reopened this issue. I do not use GA, and would appreciate clarification.

Our documentation states:

Note: The async template is not suitable for Google Analytics 4.

And it looks the regular template loads the gtag script aysnchronously.

So I assumed, perhaps incorrectly, that the async template was no longer relevant.

@kirillbobyrev
Copy link
Contributor

@jmooring oh, actually, I think you are right, sorry, I think I didn't read the code carefully enough.

The problem for me was that PageSpeed for mobile shows that the Google Analytics loading takes a long time and affects performance, so I thought that is because it isn't loaded asynchronously. But, looking closer, it isn't, so I was wrong, apologies for incorrect comment.

I think, before looking at the code closely enough, I was very confused by the documentation and the template naming, i.e. I had an impression that async loading in general is not supported by Hugo templates for GA4, whereas it seems that the _async template does not support GA4 simply because the regular one implements async loading in the first place.

I think you can close this issue, thanks for pointing me to the right code!

@jmooring
Copy link
Member

@kirillbobyrev No problem. Thanks for the clarification.

I think the documentation could use a little love:
gohugoio/hugoDocs#2061

And I think we need to deprecate the async template:
#10899

@github-actions
Copy link

github-actions bot commented May 8, 2023

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants