google / site-kit-wp

Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web.
https://sitekit.withgoogle.com
Apache License 2.0
1.25k stars 291 forks source link

Extend Consent Mode conditions for determining Ads connection status. #8382

Closed techanvil closed 7 months ago

techanvil commented 8 months ago

Feature Description

For the Consent Mode MVP, we implemented a simple check for Ads being connected which is to check for the presence of the Ads Conversion ID.

We should extend these conditions to include the additional checks discussed under "when does this apply?" in the one-pager, to the extent that it's practical to do so.

As described in the "when does this apply?" section:

For Site Kit, this affects measurement that is connected to Ads in some way. The most explicit example is the placement of an Ads conversion ID tag on the page (e.g. AW-12345678). However, this also applies to Analytics in the event where it is connected to Ads in some way, such as an Ads link (service side link between a GA4 property and Ads account), or using an Ads tag as a destination of a Google Tag (GT-, G-)

...

GTE Note: we can't look up a tag's destinations by tag ID as we'd want to do here (i.e. check the destinations of tag ID we place). We can only look up a container by a destination ID, or look up destinations by a container. GTE is odd in that it is possible to have a Google tag which is also not a destination ID so we cannot assume this either.

With the above in mind, we should extend the conditions to include the check for the Ads link, and we should also include a check for an Ads tag being a destination of a connected Google tag if we can determine a sensible way to do so.

Update: Due to the limitations of the Tag Manager API mentioned above whereby we can't lookup a tag's destinations by tag ID, we're only going to be able to manage the Ads link part of this in the short term. I (@techanvil) have created a feature request to add an endpoint to look up a container by one of its tag IDs, which would then allow us to lookup the destinations for that container via the existing destinations.list endpoint.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Implementation Brief

Note that this is basically copying the approach we take for the AdSense link status. It should be OK for now, but we might want to follow up later with some sort of abstraction around these so we don't keep repeating ourselves.

Server-side

Client-side

Test Coverage

QA Brief

  1. Set up SK with the Analytics module.
  2. Make sure you do not have an Ads conversion ID set.
  3. Run the following in the browser console googlesitekit.data.select( 'modules/analytics-4' ).getSettings() and verify that adsLinked is set to false.
  4. Link Google Ads with your configured Google Analytics property following this guide.
  5. It will need Site Kit around 24 hours to re-check if Ads is linked with Analytics. If you intend to expedite the wait time, you can use the "WP Crontrol" plugin to run the googlesitekit_cron_synchronize_ads_linked_data cron event immediately.
  6. After around 24 hours, or after manually running the cron event, the adsLinked status should now be updated. Refresh the SK dashboard and re-do step 3 to verify that adsLinked is now set to true.
  7. Verify that the Enable Consent Mode to preserve tracking for your Ads campaigns CoMo banner now appears in your SK dashboard.
  8. Verify that the "Recommended" badge now appears in Site Kit Settings -> Admin Settings -> Consent Mode.

Changelog entry

techanvil commented 7 months ago

I've raised the priority of this one as it appears that users who have Ads linked with their Analytics account are seeing a drop off in tracking without Consent Mode being enabled. Implementing this issue will ensure the setup banner on the dashboard, and the recommendations on the Settings screen are shown to more Ads users and help to mitigate this problem. See the related Slack conversation.

aaemnnosttv commented 7 months ago

Thanks @techanvil !

AC + IB ✅

One thing I noticed which relates to the issue here are the debug field definitions for the AdSense links which lack the "Analytics" prefix that all of its fields should have. Otherwise, it's not clear what module the fields are for. We could fix this for the AdSense fields here since we're touching the same part, or in a separate issue, I just thought I'd flag it here so we don't replicate that omission.

techanvil commented 7 months ago

Thanks @aaemnnosttv, good spot there. I've added an additional point to the IB to make sure we don't miss this.

mohitwp commented 7 months ago

QA Update ⚠️

Tested on dev environment.

@nfmohit I tested this using oi.ie site and manually trigger cron to link analytics and AdSense. AdSense link status is showing true but banner is not showing on main dashboard and Recommended" badge not appearing in Site Kit Settings -> Admin Settings -> Consent Mode.

Let me know if I'm missing something.

![image](https://github.com/google/site-kit-wp/assets/94359491/5a0b817e-d019-4c3a-a56d-266ea859cd98) ![image](https://github.com/google/site-kit-wp/assets/94359491/af7243c1-e62c-4533-8e29-ff53af353fae) ![image](https://github.com/google/site-kit-wp/assets/94359491/551a2185-7f74-4ac3-99f4-d9d24bf530b5)
nfmohit commented 7 months ago

Thank you for sharing your observations, @mohitwp.

I think we're having a little confusion between "Ads" linked & "AdSense" linked. We're working with adsLinked in this issue, and based on your screenshot, it looks like it isn't linked yet, i.e. adsLinked is false.

Could you ensure that it is actually linked and the cron job mentioned in the QAB is ran? Thank you!

mohitwp commented 7 months ago

QA Update ✅

![image](https://github.com/google/site-kit-wp/assets/94359491/c245e676-6ec8-4590-b461-54016ddf72c9) ![image](https://github.com/google/site-kit-wp/assets/94359491/e9d5848f-020e-4014-ac12-46d287273d68) ![image](https://github.com/google/site-kit-wp/assets/94359491/5b8d6aab-d787-4a26-99f5-2b02d104cdda) https://github.com/google/site-kit-wp/assets/94359491/c1c368b8-3c69-4efe-aeb4-e1f0d416c20b