-
Notifications
You must be signed in to change notification settings - Fork 286
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
Create conversion-tracking.js
Datastore
#8615
Comments
conversion_tracking.js
Datastoreconversion-tracking.js
Datastore
AC LGTM here, but noting that during IB we may want to consider a selector to check if conversion tracking is enable via a selector such as |
Thanks, @zutigrm. IB technically looks good to me, but I think we need to add one more thing to it. We need to make sure that when Ads or Analytics settings are saved, the conversion events tracking setting is saved as well. In order to do that, we need to call the save action from within the appropriate submit changes functions for both modules when main settings for the module are saved. |
@eugene-manuilov thanks for the comment. Basically we won't need to worry about it here, or in the settings forms, the saving should be handled in the the toggle itlself #8616, like what a consent mode switch is doing |
@zutigrm this should happen after settings have been successfully saved and only if the conversion tracking setting has changed. |
Thanks, almost looks good. The last thing let's rename |
@eugene-manuilov IB updated. Thanks |
Thanks, IB ✔️ |
QA Update
|
@mohitwp Thanks for the observations. Can you provide me more details, on how are you saving the settings/getting the snippet response? The implementation is tied to the Analytics and Ads module, so saving the conversion tracking is tied to only get triggered from the settings on these modules. |
Note : It's a fresh site on which site kit was never setup. |
@mohitwp That's fine since you are triggering it manually. In real usage the setting is saved only once button to save settings changes is hit on the settings screen of those 2 modules. Conversion event is independent and shared between these two modules, so manually invoking settings will still work independently of whether the modules are active or not |
QA Update ✅Thanks @zutigrm !
True State: False State:
Recording.982.mp4
When 'ConversionInfra' feature flaf is not enabled When both 'Analytics' and Ads module not connected |
Feature Description
With Conversion Tracking settings and associated REST controller being defined and complete (see #8612, #8613 & #8614), the appropriate datastore should be defined within the main Site Kit React application. This datastore should define the necessary actions and selectors required to save and retrieve applicable Conversion Tracking settings.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
REST_Conversion_Tracking_Controller
Class #8613Implementation Brief
assets/js/googlesitekit/datastore/site/conversion-tracking.js
assets/js/googlesitekit/datastore/site/consent-mode.js
as a starting pointgetConversionTrackingSettings
, it should usecore/site/data/conversion-tracking
endpoint for thatsaveConversionTrackingSettings
, targeting the same endpointbaseInitialState
includeconversionTrackingSettings.enabled
(dot annotates nesting), andsavedConversionTrackingSettings: undefined
saveConversionTrackingSettings
action that will use the fetch store to save the settingssetConversionTrackingEnabled
action, that will yield passed boolean value to the reducer. Reducer should updatestate.conversionTrackingSettings.enabled
valuegetConversionTrackingSettings
resolver that will usegetConversionTrackingSettings
fetch store to source the settings datastate.conversionTrackingSettings
) value from the state, and individual selector for retrieving only nestedenabled
value.hasConversionTrackingSettingChanged
selector that compares the difference betweenstate.conversionTrackingSettings
andstate.savedConversionTrackingSettings
objects, and returnstrue
if no difference is found.assets/js/googlesitekit/datastore/site/index.js
main datastoreassets/js/modules/ads/datastore/settings.js
andassets/js/modules/analytics-4/datastore/settings.js
submitChanges
functionsaveSettings
is successfuly done (no errors), check if conversion tracking settings changed (hasConversionTrackingSettingChanged
) to invokesaveConversionTrackingSettings
action onCORE_SITE
store to save conversion tracking settingTest Coverage
QA Brief
conversionInfra
feature flaggooglesitekit.data.select('core/site').getConversionTrackingSettings()
googlesitekit.data.dispatch('core/site').setConversionTrackingEnabled(true)
to change theenabled
value, you can usetrue
orfalse
googlesitekit.data.dispatch('core/site').saveConversionTrackingSettings()
enabled
valuetrue
googlesitekit.data.select('core/site').haveConversionTrackingSettingsChanged()
false
as no change happened yetgooglesitekit.data.dispatch('core/site').setConversionTrackingEnabled(false)
to change the value, and use the snippet from previous step again, it should outputtrue
as settings were updated in the stategooglesitekit.data.select('core/site').isConversionTrackingEnabled()
to verify the current value in the state. When value is set totrue
it should output it astrue
, otherwise it should befalse
Changelog entry
The text was updated successfully, but these errors were encountered: