Open techanvil opened 1 month ago
AC ✔️
Hey @techanvil, I had a deep dive into the Tag Manager docs and API and it appears I can do what is required here using existing APIs. Did I miss a way that GTM can be configured where a tags/containers can be nested in a way that requires us to look up containers to check for Ads linking? If so can you share an example of how to set up tag manager to reach this case and I will update the IB.
Feature Description
For the Consent Mode feature, we have so far implemented the check for Ads being connected to look for the presence of the Ads Conversion ID or an Ads link.
We should extend these conditions to include the additional check discussed under "when does this apply?" in the one-pager - checking for the presence of Ads tag as a destination of the connected Google Tag.
Note that we are now able to use the Tag Manager API to look up a container by tag ID, so this is now technically feasible. See the
tagId
parameter for thecontainers/lookup
endpoint and the feature request where it was introduced.Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
enabled
setting isfalse
and the banner has not been dismissed).Implementation Brief
Consent Mode backend updates
includes/Core/Consent_Mode/REST_Consent_Mode_Controller.php
, creating a new REST endpointrecommend-consent-mode
, in this endpoint:is_connected
method, if this is true, return true on the endpoint immediately.is_connected
method and if Ads is linked to Analytics by checking theadSenseLinked
setting, return true on the endpoint immediately.is_connected
method, if so:$this->get_tagmanager_service()->accounts_containers_versions->live()
to get the live version of the configured GTM tag using theaccountID
andinternalContainerID
stored in the module settings: https://github.com/google/site-kit-wp/blob/165c8bb73003e7861b3dc2eead677d034def431e/includes/Modules/Tag_Manager.php#L328-L330array_search
to check if any of the destinations in the tag[] key of the response returned for this version are of the typeawct
, which is an "Google Ads Conversion Tracking" tag, return true if so.Datastore changes
assets/js/googlesitekit/datastore/site/consent-mode.js
, create a new fetch store calledgetRecommendConsentMode
to retrieve the values from the new REST endpoint above, like so: https://github.com/google/site-kit-wp/blob/165c8bb73003e7861b3dc2eead677d034def431e/assets/js/googlesitekit/datastore/site/consent-mode.js#L80-L90Setup CTA Updates
assets/js/components/consent-mode/ConsentModeSetupCTAWidget.js
to use the newgetRecommendConsentMode
selector to render the CTA instead of theisAdsConnected
selector: https://github.com/google/site-kit-wp/blob/165c8bb73003e7861b3dc2eead677d034def431e/assets/js/components/consent-mode/ConsentModeSetupCTAWidget.js#L122-L127Recommended Badge
assets/js/components/settings/SettingsCardConsentMode.js
to use the newgetRecommendConsentMode
selector, instead of theisAdsConnected
selector to render the Recommended badge: https://github.com/google/site-kit-wp/blob/165c8bb73003e7861b3dc2eead677d034def431e/assets/js/components/settings/SettingsCardConsentMode.js#L111-L116Test Coverage
tests/phpunit/integration/Core/Consent_Mode/REST_Consent_Mode_ControllerTest.php
.QA Brief
Changelog entry