Skip to content
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

Place Ad blocking recovery and Error protection tag in the website based on Ad Blocking Recovery settings #7186

Closed
kuasha420 opened this issue Jun 20, 2023 · 4 comments
Labels
Module: AdSense Google AdSense module related issues P0 High priority Type: Enhancement Improvement of an existing feature

Comments

@kuasha420
Copy link
Collaborator

kuasha420 commented Jun 20, 2023

Feature Description

The Ad blocking recovery and error protection tag should be placed on the front end of the website once the feature is setup and the respective setting toggles are turned on regardless of whether the main AdSense tag is placed (by Site Kit or otherwise).


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

Acceptance criteria

  • Ad Blocking Recovery and error protection code should be placed in the front-end of of the website when Ad Blocking Recovery has been set up (ie. adBlockingRecoverySetupStatus is not an empty string) and their respective snippet toggles are enabled.
    • The error protection code should not be placed when the main Ad Blocking Recovery tag is not being placed.
    • The tags should be placed in all pages except for the 404 pages.
    • The tags should be placed regardless of whether Site Kit is responsible for placing the AdSense tag.
    • Nothing should be placed if the tags are not available in the Database for any reason.

Implementation Brief

  • In Google\Site_Kit\Core\Tags\Guards namespace:
    • Create WP_Query_404_Guard that implements Guard_Interface.
      • can_activate method should return ! is_404().
  • In Google\Site_Kit\Modules\AdSense namespace:
    • Create Ad_Blocking_Recovery_Tag_Guard that extends Module_Tag_Guard.
      • can_activate method should return true when adBlockingRecoverySetupStatus is not an empty string and useAdBlockerDetectionSnippet is true.
    • Create Ad_Blocking_Recovery_Web_Tag.
      • It should have protected instance fields and setters for ad_blocking_recovery_tag and use_error_protection_snippet.
      • in the render method, render the $ad_blocking_recovery->get()['tag'].
      • Also render the $ad_blocking_recovery->get()['error_protection_code'] if use_error_snippet is true.
    • In Tag_Guard:
      • In the can_activate method, remove the logic of is_404.
  • In Google\Site_Kit\Modules\AdSense.
    • In the register_tag method:
      • Add the newly created WP_Query_404_Guard to the current tag as the logic was removed previously.
      • Also instantiate the Ad_Blocking_Recovery_Web_Tag, set the fields with setters, guard and register it when adBlockerDetection is enabled and site is not in amp.
  • This PoC branch can be used as a starting point.

Test Coverage

  • Add test coverage for newly added classes.
  • Update existing tests.

QA Brief

  • Complete Ad Blocking Recovery Setup (from either main notification or settings CTA).
  • Make sure ABR toggles are enabled.
  • See that Ad Blocking Recovery and Error Protection tags are placed in Site.
  • Change toggles and ensure AC is met.
    • The last point of AC can be checked by updating the content of googlesitekit_adsense_ad_blocking_recovery_tag with garbage date ('mash keyboard') using phpMyAdmin or similar tools.. 😄

Changelog entry

  • Place Ad Blocking Recovery tags on the front end.
@kuasha420 kuasha420 added P0 High priority Type: Enhancement Improvement of an existing feature Module: AdSense Google AdSense module related issues labels Jun 20, 2023
@kuasha420 kuasha420 self-assigned this Jun 20, 2023
@kuasha420 kuasha420 removed their assignment Jun 22, 2023
@techanvil techanvil self-assigned this Jun 22, 2023
@techanvil
Copy link
Collaborator

AC ✅

@techanvil techanvil removed their assignment Jun 22, 2023
@kuasha420 kuasha420 self-assigned this Jun 22, 2023
@aaemnnosttv
Copy link
Collaborator

  • The tags should be placed in all pages except for the 404 pages.

@kuasha420 why would we require this? 🤔 The AdSense tag doesn't have this requirement/restriction (AFAIK), so it would be odd that we'd apply this differently here.

@kuasha420 kuasha420 removed their assignment Jun 26, 2023
@tofumatt tofumatt self-assigned this Jun 26, 2023
@tofumatt
Copy link
Collaborator

I'd argue it makes more sense to omit the recovery tags on 404 than normal.

The 404 page is one that the user—ideally—shouldn't be seeing (in an ideal world they wouldn't get to a 404) but if they do, they need to navigate out of to be in a usable place on the site.

We shouldn't be interrupting the flow flow of returning the user to a "good place" on the site.

Plus—they aren't really viewing any content on the 404 page (which also could be a likely entrypoint into the site from external sources—outdated/incorrect 3rd-party links or search results). So asking them to please enable ads to support content they can't see is disjointed I think.

@marrrmarrr mentioned it'd be good to omit the recovery tags from the 404 page. I think it's possibly worth doing for regular ads too, but definitely for the recovery UI.


IB ✅

@tofumatt tofumatt removed their assignment Jun 26, 2023
@kuasha420 kuasha420 self-assigned this Jun 26, 2023
@kuasha420 kuasha420 removed their assignment Jun 27, 2023
@kuasha420 kuasha420 assigned aaemnnosttv and unassigned kuasha420 Jun 28, 2023
@aaemnnosttv aaemnnosttv removed their assignment Jun 28, 2023
@wpdarren wpdarren self-assigned this Jul 3, 2023
@wpdarren
Copy link
Collaborator

wpdarren commented Jul 3, 2023

QA Update: ✅

Verified:

  • Ad Blocking Recovery and error protection code is placed in the front-end of of the website when Ad Blocking Recovery has been set up and their respective snippet toggles are enabled. The ABR toggles are enabled.
    • The error protection code is not be placed when the main Ad Blocking Recovery tag is not being placed.
    • The tags are placed in all pages except for the 404 pages.
    • Nothing is placed if the tags are not available in the Database for any reason.
    • The tags are placed regardless of whether Site Kit is responsible for placing the AdSense tag.
    • Tested that when the toggles are disabled no appropriate snippet is included in the source code.
Screenshots

image
image

@wpdarren wpdarren assigned kuasha420 and unassigned wpdarren and kuasha420 Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module: AdSense Google AdSense module related issues P0 High priority Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

5 participants