site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

Add filter to allow customisation of Consent Mode defaults.

Open techanvil opened this issue 1 year ago • 2 comments

Feature Description

At present, we provide the googlesitekit_consent_category_map filter to allow the mapping of CMP consent categories to Consent Mode parameters.

However, we don't provide a filter to allow customising the default consent values that are set. It would be useful to provide a filter so as to allow these defaults to be modified, thus allowing users complete control over the consent mode parameters.

https://github.com/google/site-kit-wp/blob/fe57e172dcdaa556fdfc7e010cb5577b6a605b91/includes/Core/Consent_Mode/Consent_Mode.php#L86-L101


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

Acceptance criteria

  • A filter named googlesitekit_consent_defaults should be added which allows the default consent parameters to be customised.

Implementation Brief

  • [ ] Add googlesitekit_consent_defaults filter for the default settings and pass current array as default value https://github.com/google/site-kit-wp/blob/fe57e172dcdaa556fdfc7e010cb5577b6a605b91/includes/Core/Consent_Mode/Consent_Mode.php#L86-L93
    • $consent_defaults = apply_filters( 'googlesitekit_consent_defaults', array(...) );

Test Coverage

  • No updates needed

QA Brief

Changelog entry

techanvil avatar Mar 12 '24 12:03 techanvil

AC ✔️

eugene-manuilov avatar Mar 12 '24 22:03 eugene-manuilov

IB ✅

tofumatt avatar Mar 21 '24 18:03 tofumatt

QA Update: ⚠️

@ankitrox @techanvil this passes the QAB, but I have two questions:

  1. When the tiler is added I am assuming it should function with the WP Consent API plugin activated and disabled? I am sure it should but I do not want to assume.
  2. Should we do any testing with the third-party consent plugins, e.g. Complianz activated? i suspect these plugins should override the filter we've added?

wpdarren avatar Apr 23 '24 02:04 wpdarren

Hi @wpdarren, this filter is essentially independent of the WP Consent API plugin status and any existing third-party plugins.

It's purely there to allow modification of the default consent parameters that Site Kit sets when the Consent Mode feature is enabled. It's conceivable that some third party plugin may decide to integrate with it in future (I don't think this is particularly likely, but it's certainly possible), but in order to do so the plugin would need to write code to explicitly make use of the filter, which has obviously just been added and is not in a SK release yet so nobody outside of our team will have actually seen and used it as of yet.

techanvil avatar Apr 23 '24 08:04 techanvil

QA Update: ✅

@techanvil thank you for the clarification there. I did think that would be the case, but wanted to double check.

Verified:

When no filter is added

  • There is the snippet available on the page as per QAB.

image

When filter is added

  • There is the snippet available on the page as per QAB for Notice ad_storage, ad_user_data and wait_for_update based on the filter used in the MU plugin.

image

wpdarren avatar Apr 23 '24 09:04 wpdarren