Add GA event tracking for the No Audiences Banner and Info Notice
Feature Description
GA events should be added to keep track of interaction with the No Audiences Banner and Info Notice.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
The following GA events should be tracked for the given actions. See the GA events sheet.
| Event Name | Category | Label | Trigger | Condition | Description/details |
|---|---|---|---|---|---|
| view_banner | {viewContext}_audiences-no-audiences | one of "none-selected" or "no-longer-available" | Element visibility | User views the "no audiences" banner | none-selected: The user views the variant where they have never had a populated selection no-longer-available: The user views the variant where their previous selection is not longer available |
| select_groups | {viewContext}_audiences-no-audiences | one of "none-selected" or "no-longer-available" | Click | User clicks the "Select groups" or "Select other groups" CTA on the banner | |
| change_settings | {viewContext}_audiences-no-audiences | one of "none-selected" or "no-longer-available" | Click | User clicks the link on the banner to navigate to Settings | |
| view_notice | {viewContext}_audiences-info-notice | one of "new-visitors", "compare-metrics", "custom-audiences", "purchasers", "returning-visitors", "compare-new-returning", "compare-cities" | Element visibility | User views a message in the Info Notice that appears below the audience tiles | These slugs represent the various messages that will be shown in the info notice |
| dismiss_notice | {viewContext}_audiences-info-notice | one of "new-visitors", "compare-metrics", "custom-audiences", "purchasers", "returning-visitors", "compare-new-returning", "compare-cities" | Click | User clicks "Got it" on the notice |
Implementation Brief
- [x] Wrap the
NoAudienceBannercomponent inforwardRef()so arefcan be passed to it, and add therefto its top-level rendered element. - [x] In the
NoAudienceBannerWidgetcomponent:- Create a version of
NoAudienceBannerwrapped by thewithIntersectionObserver()HOC, e.g.NoAudienceBannerWithIntersectionObserver. Render this in place of the existingNoAudienceBannerinstance. - Determine the
labelfor the GA event:no-longer-availablewhendidSetAudiencesis true, otherwisenone-selected. - Add an
onInViewcallback prop toNoAudienceBannerWithIntersectionObserver. In the callback, calltrackEvent( '${viewContext}_audiences-no-audiences', 'view_banner', label ).
- Create a version of
- [x] In the
NoAudienceBannercomponent:- Determine the
labelfor the GA event:no-longer-availablewhendidSetAudiencesis true, otherwisenone-selected. - Amend the
onClickhandlers for the "Select groups" / "Select other groups"Linkinstances:- Call
trackEvent( '${viewContext}_audiences-no-audiences', 'select_groups', label )prior to the call tosetValue. Chain the two calls using.finally().
- Call
- Amend the
onClickhandler for the "You can deactivate this widget in Settings"Linkinstance:- Call
trackEvent( '${viewContext}_audiences-no-audiences', 'change_settings', label )prior to the call tonavigateTo. Chain the two calls using.finally().
- Call
- Determine the
- [x] Wrap the
InfoNoticecomponent inforwardRef()so arefcan be passed to it, and add therefto its top-level rendered element. - [x] In the
InfoNoticeWidgetcomponent:- Create a version of
InfoNoticewrapped by thewithIntersectionObserver()HOC, e.g.InfoNoticeWithIntersectionObserver. Render this in place of the existingInfoNoticeinstance. - Determine the
labelfor the GA events: one ofnew-visitors,compare-metrics,custom-audiences,purchasers,returning-visitors,compare-new-returning, orcompare-cities, depending on the current notice to be displayed. - Add an
onInViewcallback prop toInfoNoticeWithIntersectionObserver. In the callback, calltrackEvent( '${viewContext}_audiences-info-notice', 'view_notice', label ). - Amend the
onDismiss()callback:- Call
trackEvent( '${viewContext}_audiences-info-notice', 'dismiss_notice', label )prior to the call todismissPrompt. Chain the two calls using.finally().
- Call
- Create a version of
- [x] Update the JSDoc for
withIntersectionObserver()to remove the point about removing the hook whenuseIntersection()has been replaced. The HOC is a useful abstraction around a common pattern ofuseIntersection()usage that we can keep for the longer term.
Test Coverage
- Add coverage for the above changes to the tests for
NoAudienceBannerandNoAudienceBannerWidget.
QA Brief
- As a prerequisite for testing the events for each component:
- Have a mechanism for checking tracked Analytics events ready, e.g. Tag Assistant or the Google Analytics Debugger Chrome extension.
- Set up Site Kit with the
audienceSegmentationfeature flag enabled, tracking enabled, and Analytics connected using a property which is out of the gathering data state. - Click on Enable groups to set the feature up.
No Audiences Banner
- Events with the
no-longer-availablelabel:- Archive all of the audiences for the connected property barring "All Users".
- Refresh the Site Kit dashboard and open the Audience Selection Panel to trigger a resync of the available audiences.
- The No Audiences Banner should appear, showing the "It looks like your visitor groups aren’t available anymore" message.
- Verify the
view_bannerevent is tracked with the labelno-longer-availableas per the AC. - Click on Select other groups in the banner.
- Verify the
select_groupsevent is tracked with the labelno-longer-availableas per the AC. - Click on Settings in the banner.
- Verify the
change_settingsevent is tracked with the labelno-longer-availableas per the AC.
- Events with
none-selectedlabel:- Continuing with the flow above, login as a second admin user and connect Site Kit. The second admin should have view access or higher for the connected property.
- The No Audiences Banner should appear, showing the "You don’t have any visitor groups selected" message.
- Verify the
view_bannerevent is tracked with the labelnone-selectedas per the AC. - Click on Select groups in the banner.
- Verify the
select_groupsevent is tracked with the labelnone-selectedas per the AC. - Click on Settings in the banner.
- Verify the
change_settingsevent is tracked with the labelnone-selectedas per the AC.
Info Notice
- Follow the QAB for https://github.com/google/site-kit-wp/issues/8139, repeating point 9 with the values of
0to6inclusive forcountin order to iterate through the sequence of Info Notice messages:
- Once a notice is dismissed, it takes two weeks for the next notice to appear. To be able to see any notice immediately, try the following script in the browser console:
googlesitekit.data.dispatch('core/user').receiveGetDismissedPrompts( { 'audience-segmentation-info-notice': { expires: Math.floor( Date.now() / 1000 ) - 10, count: 0 // Change this to any number of notice that you intend to see (0 - 6). } } );
- Each time a message is shown:
- Verify the
view_noticeevent is tracked with the correct label as per the AC. - Click on Got it in the notice and verify the
dismiss_noticeevent is tracked with the correct label as per the AC.
- Verify the
Changelog entry
- Add GA event tracking for user interactions with the No Audiences Banner and Info Notice.
Thank you for drafting the IB, @techanvil !
- Determine the
labelfor the GA event:none-selectedwhendidSetAudiencesis true, otherwiseno-longer-available.
To confirm, shouldn't this be the other way around, i.e. none-selected when didSetAudiences is false, otherwise no-longer-available?
Please confirm, thank you!
Thanks for catching that @nfmohit! You are spot on, it should be the other way round. I've fixed the IB, back over to you! 🦅 👁
Thank you Tom! IB ✅
QA Update ✅
Verified the GTM events as per the table in ACs and all are being triggered accordingly. Moving ticket to approval.
-
no-longer-availablelabelview_banner:select_groups:
change_settings:
-
none-selectedlabelview_banner:select_groups:
change_settings:
-
new-visitorslabelview_notice:dimiss_notice:
-
compare-metricslabelview_notice:dimiss_notice:
-
custom-audienceslabelview_notice:
dimiss_notice:
-
purchaserslabelview_notice:dimiss_notice:
-
returning-visitorslabelview_notice:dimiss_notice:
-
compare-new-returninglabelview_notice:dimiss_notice:
-
compare-cities labelview_notice:dimiss_notice: