Implement/refactor GA tracking events for plugin setup
See original GitHub issueFeature Description
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The following new GA tracking events should be triggered on the Site Kit plugin activation notice:
view_notification
: Should be triggered on page load/notice visibility when the notice is shown.confirm_notification
: Should be triggered when the user clicks on the primary button in the notice, no matter what the button is set to do.- The
plugin_activated
,proxy_start_setup_banner
andgoto_sitekit
events currently used should be removed. start_site_setup
: Should be triggered together with the aboveconfirm_notification
if both of the following is true:- The button will start the plugin setup flow (i.e. not just take the user to the dashboard).
- The site isn’t connected yet (i.e. there are no site credentials stored yet).
- The event should also receive a label: either “proxy” or “custom-oauth” depending on whether the proxy is used (99% of cases) or not.
start_user_setup
: Should be triggered together with the aboveconfirm_notification
(and possiblystart_site_setup
) if the following is true:- The button will start the plugin setup flow (i.e. not just take the user to the dashboard).
- The event should also receive a label: either “proxy” or “custom-oauth” depending on whether the proxy is used (99% of cases) or not.
- In other words,
start_site_setup
is only for when the site is first connecting,start_user_setup
is anytime a user connects (which includes the first time, where basically both of this happens as part of the plugin setup). This means that for example, the very first time that the CTA button is clicked, all three eventsconfirm_notification
,start_site_setup
, andstart_user_setup
should be triggered. - All of the above events should use “activation” (
VIEW_CONTEXT_ACTIVATION
) as the event category.
- The following new GA tracking events should be triggered on the Site Kit splash screen:
start_site_setup
: Should be triggered when the CTA button is clicked, under the same conditions as the event of the same name on the activation notice above. It should also have the same label (“proxy” or “custom-oauth”).start_user_setup
: Should be triggered when the CTA button is clicked, under the same conditions as the event of the same name on the activation notice above. It should also have the same label (“proxy” or “custom-oauth”).- The
proxy_start_setup_landing_page
andsignin_with_google
events currently used should be removed. - In other words, like on the activation notice,
start_user_setup
should be triggered in every case for the setup.start_site_setup
should only be triggered when there are no site credentials yet (typically only the first time, unless the plugin is reset). - All of the above events should use “splash” (
VIEW_CONTEXT_SPLASH
) as the event category.
- The following new GA tracking events should be triggered on the dashboard success notification (e.g. after setting up the plugin or a module):
view_notification
: Should be triggered when the notification is rendered.confirm_notification
: Should be triggered when the user clicks “Ok, got it”.complete_site_setup
: Should be triggered together with the aboveview_notification
if both of the following is true:- The notification is shown because of a successful plugin setup (i.e. not because of a successful module setup).
- Part of this plugin setup flow was to connect the site. A reasonable check to determine that could be to check that only one administrator is connected (since the site itself gets connected as part of connecting the first user).
- The event should also receive a label: either “proxy” or “custom-oauth” depending on whether the proxy is used (99% of cases) or not.
complete_user_setup
: Should be triggered together with the aboveview_notification
(and possiblycomplete_site_setup
) if the following is true:- The notification is shown because of a successful plugin setup (i.e. not because of a successful module setup).
- The event should also receive a label: either “proxy” or “custom-oauth” depending on whether the proxy is used (99% of cases) or not.
- In other words, if
complete_site_setup
fires,complete_user_setup
must also fire (that would be the initial setup). On subsequent connections (which only connect the current user, not the site) onlycomplete_user_setup
should fire.
- All of the above events should use “dashboard_authentication-success_notification” (relying on
VIEW_CONTEXT_DASHBOARD
for the “dashboard” part) as the event category. - Note that this notification is also touched for one event change as part of #4004, so this may require some coordination if happening at the same time.
Implementation Brief
trackEvent
mentioned in the bullet points below should be imported fromassets/js/util/tracking/index.js
- Using
assets/js/components/activation/activation-app.js
,- Use the
useMount
hook to call thetrackEvent
withview_notification
as action. - Use the
isConnected
selector of the site data store to know whether the site is connected. - Use the
isUsingProxy
selector of the site data store to know whether the proxy is being used. - Within the
onButtonClick
function,- Update the call to
trackEvent
withconfirm_notification
as action (removing the existingplugin_setup
action and associated label). - If
proxySetupURL
istrue
, call thetrackEvent
function again, withstart_user_setup
as action, passingproxy
as label if the result ofisUsingProxy
istrue
, else passcustom-oauth
as label. - If
proxySetupURL
istrue
andisConnected
it nottrue
, call thetrackEvent
function again, withstart_site_setup
as action, passingproxy
as label if the result ofisUsingProxy
istrue
, else passcustom-oauth
as label.
- Update the call to
- All of the above events should use “activation” (
VIEW_CONTEXT_ACTIVATION
imported fromassets/js/googlesitekit/constants.js
) as the event category.
- Use the
- Using
assets/js/googlesitekit-activation.js
, remove thetrackEvent
call. - Using
assets/js/components/setup/SetupUsingProxy.js
,- Within the
onButtonClick
function,- Implement the
start_site_setup
andstart_user_setup
tracking calls as mentioned above forassets/js/components/activation/activation-app.js
. The label can be hard coded toproxy
since the component is rendered only if the proxy is used.
- Implement the
- All of the above events should use “splash” (
VIEW_CONTEXT_SPLASH
imported fromassets/js/googlesitekit/constants.js
) as the event category.
- Within the
- Using
assets/js/components/legacy-setup/SetupUsingGCP.js
,- Within the
onClick
callback for theSign in with Google
, implement thestart_site_setup
andstart_user_setup
tracking calls as mentioned above forassets/js/components/activation/activation-app.js
. The label can be hard coded tocustom-oauth
instead of checking whether the proxy is used since the component is rendered only if proxy authentication is not used. - All of the above events should use “splash” (
VIEW_CONTEXT_SPLASH
imported fromassets/js/googlesitekit/constants.js
) as the event category.
- Within the
- Remove the
trackEvent
call havingsignin_with_google
as action fromassets/js/components/legacy-setup/wizard-step-authentication.js
andassets/js/components/legacy-setup/SetupUsingGCP.js
. - Using
assets/js/components/legacy-notifications/dashboard-setup-alerts.js
,- Use the
hasMultipleAdmins
selector of the site data store to check if there is only 1 admin. It should returntrue
if the site has multiple admins,false
if it has just one admin. - Use the
isConnected
selector of the site data store to know whether the site is connected. - Use the
isUsingProxy
selector of the site data store to know whether the proxy is being used. - Use the
useMount
hook:- to call
trackEvent
withview_notification
as action. - if
slug
isnull
, calltrackEvent
withcomplete_user_setup
as action and passingproxy
as label if the result ofisUsingProxy
istrue
, else passcustom-oauth
as label. - if
slug
isnull
and there is only one connected admins, calltrackEvent
withcomplete_site_setup
as action and passingproxy
as label if the result ofisUsingProxy
istrue
, else passcustom-oauth
as label.
- to call
- Add the
onDismiss
prop toNotification
within theauthentication_success
test and the callback function should calltrackEvent
withconfirm_notification
as action. - All of the above events should use “dashboard” (
VIEW_CONTEXT_DASHBOARD
imported fromassets/js/googlesitekit/constants.js
) as the event category.
- Use the
Test Coverage
- No new tests to be added.
QA Brief
- Verify that the events listed in the AC are all present and correct.
Changelog entry
- Update plugin setup tracking events for users who have opted-in to tracking.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
How to set up event tracking in Google Analytics
There are two different ways you can set up event tracking in Google Analytics. One way is to add the code manually. The...
Read more >How to Set Up Google Analytics Event Tracking - Hootsuite Blog
To understand Google Analytics event tracking, you first have to ... by installing and activating the Insert Headers and Footers plugin.
Read more >How to Set Up Google Analytics Event Tracking in WordPress
Google Analytics events are a way to track clicks on parts of your website like links, buttons, and videos. This allows you to...
Read more >Using Google Analytics Event Tracking - Hallam Internet
In this post, I explain how to track events manually by editing the code on your site or by using Google Tag Manager...
Read more >How to Add Google Analytics Event Tracking in WordPress
You can track pageviews, referral source, time spent on page, and much more by simply installing Google Analytics, but for more in-depth ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@kuasha420 @aaemnnosttv I think it’s okay we don’t have special treatment for this event. User event tracking in that sense is always somewhat inconsistent (as they can opt-in and opt-out at any time), so I think this is acceptable. We still shouldn’t ditch the event entirely, as it could still fire if someone opts in, deactivates the plugin and reactivates it again. We mostly need to be aware of this caveat when assessing the metrics.
That is correct; the rest of the event tracking you experienced seems correct, and originally I thought we should special-case this one and put it in a
useEffect
+ track when we send it, rather than putting it in auseMount
, because tracking will likely be disabled on first load.But that requires us doing this everywhere and isn’t very nice. I think this issue actually passes QA but we need to improve event storage when tracking is disabled: https://github.com/google/site-kit-wp/blob/6101771d0653fec3db89876eecc9013ee3e5f1f7/assets/js/util/tracking/createTrackEvent.js#L44
Maybe it can be part of the #3051 epic, for now I’ve made a note of it and will file a follow-up issue when needed. 👍🏻
This is correct, they’re different categories of notifications and it’s fine for both to fire, from the ACs of each issue.
So I think this is QA ✅ , thanks for checking on it @kuasha420 👍🏻