A4A: Setup Google Analytics.
This PR updates the Google Analytics package to recognize the A4A environment and use the correct Gtag ID. The main goal is for the initial setup. We can track page views.
Proposed Changes
- Add A4A GTag constant and update Google analytics setup function to recognize A4A environment.
Why are these changes being made?
- Google Analytics provides an easy way to track users' journeys and measure user engagement at a high-level visuals. This PR setups GA to work with A4A using A4A-specific properties (Gtag IDs).
Testing Instructions
- Before testing, sign up for an agency account
/signup. - Use the A4A live link below and go to
/overview?flags=ad-tracking - Confirm that the Network request is made to https://www.googletagmanager.com/gtag/js?id=G-8V8PCRJ142
Pre-merge Checklist
- [ ] Has the general commit checklist been followed? (PCYsg-hS-p2)
- [ ] https://wpcalypso.wordpress.com/devdocs/docs/testing/index.md for your changes?
- [ ] Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
- [ ] Have you checked for TypeScript, React or other console errors?
- [ ] Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
- [ ] Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
- [ ] For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?
Jetpack Cloud live (direct link)
|
|
https://calypso.live?image=registry.a8c.com/calypso/app:build-110726&env=jetpack |
Automattic for Agencies live (direct link)
|
|
https://calypso.live?image=registry.a8c.com/calypso/app:build-110726&env=a8c-for-agencies |
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:
App Entrypoints (~258 bytes added 📈 [gzipped])
name parsed_size gzip_size
entry-subscriptions +621 B (+0.0%) +170 B (+0.0%)
entry-stepper +334 B (+0.0%) +73 B (+0.0%)
entry-main +334 B (+0.0%) +73 B (+0.0%)
entry-login +323 B (+0.0%) +88 B (+0.0%)
entry-domains-landing -41 B (-0.0%) -15 B (-0.0%)
entry-browsehappy -41 B (-0.0%) -15 B (-0.0%)
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.
Sections (~6221 bytes removed 📉 [gzipped])
name parsed_size gzip_size
a8c-for-agencies-signup +554 B (+0.7%) +634 B (+2.2%)
a8c-for-agencies-settings +554 B (+0.3%) +442 B (+0.8%)
a8c-for-agencies-sites +399 B (+0.0%) +73 B (+0.0%)
a8c-for-agencies-purchases +399 B (+0.1%) +110 B (+0.1%)
a8c-for-agencies-marketplace +399 B (+0.1%) +72 B (+0.0%)
a8c-for-agencies-referrals +358 B (+0.1%) +47 B (+0.0%)
a8c-for-agencies-partner-directory +358 B (+0.1%) -9 B (-0.0%)
a8c-for-agencies-overview +358 B (+0.2%) -16 B (-0.0%)
a8c-for-agencies-migrations +358 B (+0.2%) -10 B (-0.0%)
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.
Legend
What is parsed and gzip size?
Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.
Generated by performance advisor bot at iscalypsofastyet.com.
This PR modifies the release build for the following Calypso Apps:
For info about this notification, see here: PCYsg-OT6-p2
- blaze-dashboard
- editing-toolkit
- notifications
- odyssey-stats
- wpcom-block-editor
To test WordPress.com changes, run install-plugin.sh $pluginSlug add/a4a/google-analytics on your sandbox.
I am Adding Martech as a reviewer to double-check that I am changing the right files and covering everything needed for the initial setup.
I am Adding Martech as a reviewer to double-check that I am changing the right files and covering everything needed for the initial setup.
Hmm, I tried functional testing per the testing instructions above, however I am not seeing any googletagmanager tracking requests... 🤔 @robertsreberski, would you mind giving this PR a look/review?
@elliottprogrammer, Thank you for looking into this. You may need to sign up for an Agency account. I'll add it in the test instructions.
https://agencies.automattic.com/signup
Thanks everyone for the great feedback. I truly appreciate it. I apologize for the delay in responding to the PR. I had some other stuff to prioritize.
I've made some adjustments to address the comments made. 🙏
It should be something like this:
<PageViewTracker title="Overview" path={ context.path } options={ { useA8CForAgenciesGoogleAnalytics: true } } />So to leverage the changes from
client/lib/analytics/page-view.js.
Thanks. I've made the necessary changes so all pages pass the correct options.
https://github.com/Automattic/wp-calypso/pull/90805/commits/28d4ca1d9e309072e45b61f551cfc92d5b0c9101