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

Add Google Analytics GA4 code (Issue #45) #48

Merged
merged 1 commit into from
Feb 16, 2021

Conversation

Kolossi
Copy link

@Kolossi Kolossi commented Feb 6, 2021

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

@amitmerchant1990
Copy link
Owner

Thanks for the PR @Kolossi.

I would just suggest you move the logic to _includes/analytics.html file instead of creating a separate file. As I think, all the analytics code should live in a single file so it becomes more maintainable.

Thanks!

@Kolossi
Copy link
Author

Kolossi commented Feb 12, 2021

Thx.

I sure would have done, but the reason I didn't is one style needs to go in head, the other in body. Any ideas how to tackle that?

@amitmerchant1990 amitmerchant1990 merged commit c6edc6d into amitmerchant1990:master Feb 16, 2021
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 this pull request may close these issues.

None yet

2 participants