site-kit-wp: Ad blocker warning message is inconsistent in different locations
It says " Ad blocker detected, you need to disable it in order to set up AdSense."
However, the AdSense setup has already been done and I can see that AdSense is working properly.
Maybe the message should say “Ad blocker detected, you need to disable it in order for AdSense to work properly.”
Steps to reproduce
- Setup AdSense on Site Kit without any Ad Blockers
- Enable an adblocker. In this instance, I used https://adblockplus.org/
- Open the AdSense details page.
- You can see the above error. Also seen on the AdSense module on the dashboard.
Screenshots

Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The ad blocker warning should be consistent in all locations under the same conditions. Currently the locations are as follows:
- Setup CTA (from SK success notification on main dashboard)
- Setup module (on Connect More Services tab of settings)
- AdSense settings view (when setup is incomplete)
- AdSense setup
- Dashboard summary widget
- Dashboard top earning pages widget (only shown when Analytics is also activated and linked with the connected AdSense account)
- The module page will be covered separately in #4178
- A new
getAdBlockerWarningMessageselector should be added to the AdSense datastore to be used in both places - The logic in the
AdBlockerWarningcomponent for determining which message to use should be simplified to come from the newgetAdBlockerWarningMessageselector rather than using its own logic based on site and account setup completion.
Implementation Brief
Inside assets/js/modules/adsense/datastore/adblocker.js
- Add a new selector,
getAdBlockerWarningMessagewith the following logic:- if there is no ad blocker, return
null - if the AdSense module is connected and there is an ad blocker, return ‘Ad blocker detected, you need to disable it to get the AdSense latest data.’
- if the AdSense module is not connected and there is an ad blocker, return ‘Ad blocker detected, you need to disable it in order to set up AdSense.’
- Make sure to use i18n for the messages, i.e.
__( 'Ad blocker detected, you need to disable it in order to set up AdSense.','google-site-kit' ) - You can use the AdSense module’s
isAdBlockerActiveto determine if the Ad Blocker is active. - You can use the
select( CORE_MODULES ).isModuleConnectedto determine if the AdSense module is connected. - Add test coverage to
assets/js/modules/adsense/datastore/adblocker.test.jsfor this new selector.
- if there is no ad blocker, return
Inside assets/js/modules/adsense/index.js:
- Refactor the
checkRequirementslogic to use the new selector instead ofisAdBlockerActive - If the selector returns
null/ falsey, return (as it does currently). - Otherwise throw (as it does currently), but pass the message returned by the selector.
Inside assets/js/modules/adsense/components/common/AdBlockerWarning.js:
- Refactor the logic by removing the current use of
isAccountSetupCompleteandisSiteSetupCompleteand replacing them with a call to the new selector. - If the selector returns
null/ falsey, returnnullfrom the component. - Otherwise, render the message returned by the selector.
Test Coverage
- See above: coverage will be needed for the new selector.
Visual Regression Changes
- Images relating to the ad blocker messages may need updating.
QA Brief
- Check for the correct adblock warning message when adsense module is connected and not connected and adblock is active.
- The warning messages should match the one in the AC.
- Newly added and update unit tests should also pass.
Changelog entry
- Fix wording of ad blocker warning to always reflect the current state of the AdSense module.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (3 by maintainers)
QA Update: ✅
As per conversation, this ticket is verified:
Checked all areas in the AC, i.e. when AdSense is not set up, but Adblocker is enabled, I see the message
Ad blocker detected, you need to disable it in order to set up AdSense.on the ‘Connect more Services’ and Site Kit Dashboard CTA banner when you connect Site Kit. - Screenshot 1 - Screenshot 2The initial issue reported will be fixed in #4178.
@wpdarren @aaemnnosttv @kuasha420 Per our conversation in the meeting, this can be considered done. Let’s prioritize #4178 for next sprint. cc @eclarke1 @fhollis
@wpdarren, yes, both statements are correct. We need to figure out why we don’t see the second message on the AdSense module page. I think we can consider this ticket as such that is not passed QA.
@aaemnnosttv Makes sense. Another nit-pick enhancement/simplification we could make as part of this potentially: Right now the condition to decide between the two messages in
AdBlockerWarningis unnecessarily complicated. A simpleisAdSenseModuleConnectedwould work and be more decoupled from the AdSense setup details currently used.