Create `Ads` Module Site Health Checks
Feature Description
As part of the new Ads module work being implemented, new Site Health checks are required to be added. These Site Health checks will be present in the Site Health > Info section, and appear within the Site Kit by Google health check group.
Checks will include the following:
- Display of the
Ads Conversion IDfield value - An indication of whether the Ads Conversion ID script is being rendered/output on the site
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The following Site Health checks will appear within the
Site Health > Infosection, and appear within theSite Kit by Googlehealth check group:- Output of the currently store Ads Conversion ID field value
- Indication of whether the Ads Conversion ID snippet is being rendered on the frontend
Implementation Brief
- [x] Add
includes/Modules/Ads/Tag_Matchers.php- Use
includes/Modules/AdSense/Tag_Matchers.phpas a starting point. - Modify the regex array to match the ads code pattern, which is added in the gtag as
gtag('config','AW-12345'). Ads conversion ID will always start withAW-
- Use
- [x] Update
Google\Site_Kit\Modules\Adsclass:- Class should implement
Module_With_Debug_FieldsandModule_With_Taginterfaces - It should use
Module_With_Tag_Traittrait - Add
get_debug_fieldsmethod, it should outputadsConversionIDsetting. You can see the example of implementation in any other module, for exampleGoogle\Site_Kit\Modules\AdSense::get_debug_fields - Add
get_tag_matchersmethod, which should return the new Ads moduleTag_Matchersclass
- Class should implement
Test Coverage
- Update
tests/phpunit/integration/Modules/AdsTest.php, to include test case forget_debug_fields
QA Brief
- Enable the
adsModulefeature flag and connect the Ads module in the SK settings. - Add the Conversion ID to both the Ads module settings and the Analytics 4 settings.
- Enable the Ads tag placement.
- Go to
Tools > Site Health, select theInfotab and open theSite Kit by Googleaccordion- Check the Ads Conversion ID is shown
- Go to
Tools > Site Health, then clickPassed Testsand expand theTag Placementaccordion- Check the Tag Placement is shown. It will currently show: "Tag detected but could not verify that Site Kit placed the tag." because the Analytics module owns the tag not the Ads module.
Changelog entry
@10upsimon, the current AC is more like IB. We don't need to go into that much details there. Just top level requirements should be added that describe the final result instead of how we need to do it.
In the context of the current ticket, the final results are that we display site health information for the Ads module and it shows conversion id and whether the snippet information. I think we don't even need to declare which class we need to implement in the module class because that is a part of IB after all (i know that we did it like this in other tickets, but that is excessive i think).
@eugene-manuilov this is back with you, greatly simplified
Yeah, AC 🌶️
IB ✔️
Hi @10upsimon, As discussed on Slack, the QAB needs to be updated. Can you please update it and set the QA:Eng label?
Update: Let's set this ticket blocked by #8348. Hence we don't need QA:Eng.
cc: @benbowler
Flagging that this is still blocked until we have #8251 merged. It's pending merge of that purely from a setup perspective so that we do not need a QA:ENG approach. The code is good to go, hence it's still in CR.
@zutigrm With #8251 now merged, I think this should be good to go? Reassigning to you.
QA Update: ❌
@benbowler we have now renamed Ads Conversion ID to Conversion Tracking ID so we should rename the title in the Info tab to this new title.
Thanks @wpdarren, I've updated this title and will move to CR once checks pass.
@wpdarren The follow up PR is now merged. Remember to test on main. Cheers.
QA Update: ✅
Verified:
- When I select the Info tab and open the Site Kit by Google accordion, the ID is shown
- When I click Passed Tests and expand the Tag Placement accordion, the Tag Placement is shown.
- When I connect Analytics and on Site Health, then click Passed Tests and expand the Tag Placement accordion
It shows the same as above:
Tag detected and placed by Site Kit. - When I disable the Place Google Analytics code setting for the Analytics module and the Tag placement for the Ads module, it shows the same message:
Tag detected and placed by Site Kit.
Screenshots
@benbowler we have now renamed
Ads Conversion IDtoConversion Tracking IDso we should rename the title in the Info tab to this new title.
@wpdarren @kuasha420 it's correct to update the field for consistency, but all module fields should be prefixed with the module name in the Site Health table. It's less obvious with the Ads module since it only has one field but when in doubt, it's good to look at other modules 👍
Also, the label and field key (used in debug output copied to clipboard) should match.
I'll open a quick PR for this fix.
No additional QA needed here as it's just a string change + the masking of the value. I've verified the change in Local while Code Reviewing. Moving back to approval. :tada: