Closed 10upsimon closed 1 month ago
✅ AC Looks good, moving to IB, thanks @zutigrm
IB looks to be okay-ish, but the ticket says that we need to create the Scheduled_Events_Check
class that we don't mention in the ticket description at all. @10upsimon, do we really need to have that class or we can use the approach defined in IB? Also I have slightly updated AC not to mention the specific class name.
@eugene-manuilov I can hop in to answer this, the mentioned class is included in the issue, since when we discussed the initial plan of implementation we though of going with one class to handle the logic. But I split this in IB, to propose using single purpose lean classes, to align with the approach of having leaner classes similarly to what @aaemnnosttv used in Remote Features classes recently.
We do not mandatorily need to use the Scheduled_Events_Check
class, I can rename the issue, but also I will pick this up for execution when it lands in EB
@zutigrm this LGTM, thanks for adding the line indicating that we do not inherently need to implement the Scheduled_Events_Check
class, I agree that if it is not necessary hen it's pointless adding it.
Moving this to EB.
@mohitwp I updated QAB, to reflect recent change - recentEvents
option is renamed to the detectedEvents
detectedevents
which will hold array type value is added to the existing Analytics settingsdetectedEvents
key in the outputted array, contain ['purchase', 'submit_lead_form' ]as a value if connected GA4 account/property has ACR data.detectedEvents
has empty array [] as a value if connected GA4 account/property don't have ACR data.@mohitwp I updated QAB, to reflect recent change -
recentEvents
option is renamed to thedetectedEvents
@zutigrm this is okay since we discussed it, but it's important to make sure this is updated in the AC since it specifically mentions the key name to use there.
Also, there are a few references to the old name in properties/docs throughout which should be updated from "check" to "sync". E.g.
Please address these with a quick follow-up for the release, thanks.
@aaemnnosttv I've created a follow up PR at https://github.com/google/site-kit-wp/pull/9310 which addresses the code inconsistencies from a check vs sync naming point of view.
I've also updated both the AC and IB of the issue to correctly reference events_sync
as a property name, and correctly reference Conversion_Reporting_Events_Sync
in var declarations.
Feature Description
As part of the initial body of work for the ACR epic is the requirement to ascertain which events are detected within a users GA4 report data, in order to understand the metrics we should make available to them. In order to obtain this data, a single
daily
event will be scheduled in response to dashboard use.Said scheduled event will make a request via the GA4 Data API, asking for data over the past 90 days containing either of the supported event metrics:
addToCarts
ecommercePurchases
submit_lead_form
generate_lead
contact
Based on the results of the report response, an applicable array of events present in the users report data over the past 90 days will be stored in the existing GA4 settings option against a
recentEvents
key.The value of this option (obtained from the
recentEvents
key therein) will be used in various areas of the code to determine what we do and do not show to the end user regarding the Analytics Conversion Reporting metrics.See the relevant section of the design document for more information.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
detectedEvents
which will hold array type value is added to the existing Analytics settingsrecentEvents
setting:add_to_cart
purchase
submit_lead_form
generate_lead
contact
Implementation Brief
Note: Even though issue title mentions the creation of a
Scheduled_Events_Check
, the implementation doesn't have to be done via a single class as long as the event is logically and correctly scheduled.[ ] Update
includes/Modules/Analytics_4/Settings.php
get_default
method includerecentEvents
key with an empty array[ ] Add
includes/Modules/Analytics_4/Conversion_Reporting/Conversion_Reporting_Cron.php
includes/Core/Remote_Features/Remote_Features_Cron.php
wp_schedule_single_event
)DAY_IN_SECONDS
for time[ ] Add
includes/Modules/Analytics_4/Conversion_Reporting/Conversion_Reporting_Events_Sync.php
Analytics_4
module instances in constructor and assign it to the class propertycheck_for_events
methodget_data
method ofanalytics_4
instance ($this->analytics_4->get_data( 'report', $options )
). Report options should:eventName
fordimensions
arraygmdate( 'Y-m-d' )
forendDate
gmdate( 'Y-m-d', strtotime( '-90 days' ) )
forstartDate
dimensionFilters
foreventName
and useinListFilter
to filter for the event names array listed in the ACrecentEvents
settings key. Results will contain event names that are present under each returneddimensionValues
in resultingrows
property[ ] Add
includes/Modules/Analytics_4/Conversion_Reporting/Conversion_Reporting_Provider.php
includes/Core/Remote_Features/Remote_Features_Provider.php
analytics_4
instances inconstructor
, and assign them to the class propertiesConversion_Reporting_Events_Sync
andConversion_Reporting_Cron
classes and forConversion_Reporting_Cron
usecheck_for_events
method fromConversion_Reporting_Events_Sync
as a callback argument.register
method and invokeregister
method ofConversion_Reporting_Cron
instance, and hook into the dashboard screenload-toplevel_page_googlesitekit-dashboard
. As callback invokemaybe_schedule_cron
method fromConversion_Reporting_Cron
class.Update
includes/Modules/Analytics_4.php
- instantiate newConversion_Reporting_Provider
class and invoke it'sregister
method inAnalytics_4::register
ifconversionReporting
feature flag is enabledTest Coverage
Remote_Features_*
classes for ideasQA Brief
conversionReporting
feature flag enabledWP Crontrol
plugin and triggergooglesitekit_cron_conversion_reporting_events
eventawait googlesitekit.api.get('modules', 'analytics-4', 'settings', {}, {useCache: false});
detectedEvents
key in the outputted array, it should contain['purchase', 'submit_lead_form']
as a valuerecentEvents
has empty array[]
as a value['purchase', 'submit_lead_form']
Changelog entry