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 4 support #74

Merged
merged 3 commits into from
Sep 15, 2023
Merged

Add google analytics 4 support #74

merged 3 commits into from
Sep 15, 2023

Conversation

tgaff
Copy link
Contributor

@tgaff tgaff commented Sep 12, 2023

The GA built into this theme is the old UA version which ceased processing data in July. This sets up GA4 instead.

I've submitted similar code to hydejack in PR330. Based on other issues/PRs on that repo its not likely to be merged soon. In this PR I've torn out most of the complexity that I'm unable to test (not having a pro license) and we don't use anyway.

A variation of this was tested on my fork.

Edit: GA indicates its received some pings in the last 24 hours so I think this is working.

@tgaff tgaff temporarily deployed to github-pages September 12, 2023 05:20 — with GitHub Pages Inactive

w.loadJSDeferred('https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}');
}(window, document);</script>
{% endif %}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a combination of liquid/jekyll code wrapping JS here. The JS is by and large what Google suggests just with the necessary Jekyll/theme stuff merged in.

Screen Shot 2023-09-15 at 9 40 44 AM

@@ -60,3 +60,6 @@ titles_from_headings:
# - languages/index.md
# - process/speclet_playbook.md
# - process/testing_strategy.md


google_analytics: G-2NX5YFW46E
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assume this is ok to be in the repo?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I see what's going on below. so do we want the value in the repo or 🤷

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confirmed BY_DESIGN approved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, for future reference this is not a secret. It'll show up many times in the network tab as part of URLs. It's just the way GA works. If someone else wants to steal it, they're welcome to enjoy their console.log'd wrong domain messages courtesy of GA.

@tgaff tgaff merged commit 9934205 into master Sep 15, 2023
@tgaff tgaff deleted the ga branch September 15, 2023 01:16
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.

2 participants