Add Google Analytics GA4 code (Issue #45) #48
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Amit,
Thanks for all your work on this great theme.
I noticed Issue #45 about new style "GA4" analytics and I had already fixed it in my generated version, so here is a PR for you to review.
There's different ways to tackle this - maybe auto-detect by looking at the form of the
google_analytics
id given ("G-..." or "UA-...").In my version I just used 2 config values. It also looks if GA4 is set and if so doesnt include the old UA stuff. Someone might want it though I guess, so I didn't do that in this PR.
(To do it, my
analytics.html
line 1:{% if site.google_analytics_ua and not site.google_analytics_ga4 %}
)Note that as I'm starting fresh, in my site I also renamed the existing
google_analytics
togoogle_analytics_ua
but that's very "breaky" for existing users!Anyway, this PR as it is seems to me like a non-breaking easy implementation for the main repo.
YMMV, but my wish is that this at least saves you a little time in addressing the issue.
Thanks again for a great theme.
Paul