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

Existing official AdSense snippet not detected

Open aaemnnosttv opened this issue 7 years ago • 3 comments

Bug Description

Site Kit's existing tag detection for AdSense does not detect the snippet provided by AdSense for users to put on their site.

<script data-ad-client="ca-pub-1234567890" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

Steps to reproduce

  1. Manually place the html snippet provided by AdSense on the homepage
  2. Set up AdSense module
  3. Existing tag is not found, setup completes as usual

Expected (or similar)

image The above is using a dummy publisher ID

Saw

image

Screenshots

image


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

Acceptance criteria

  • The following type of AdSense snippet should be detected when it exists on the frontend:
    <script data-ad-client="ca-pub-1234567890" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    

Implementation Brief

  • Update AdSense regex to check for script tags as well
    /<(?:script|amp-auto-ads) [^>]*data-ad-client="([^"]+)"/gm
    

Changelog entry

  • Improve detection of existing AdSense snippets to cover more variants of snippets.

aaemnnosttv avatar Nov 05 '19 16:11 aaemnnosttv

IB ✅

felixarntz avatar Nov 07 '19 20:11 felixarntz

Tested

I adjusted the code for Adsense to trigger the above copy using a dummy ID. image

Adjusted the code for Adsense to find my domain as a positive test.

Adsense code: image

Adsense Google user: Username: [email protected] Password: gpev8D1DiVq9X8g

Adsense account: image

Code on my host: image

Setup prompt image

One thing to note the Continue link pops a new tab and refreshes the Adsense connection setup

Need some insight as to what I should adjust to be able to have Adsense see the code. This isn't a pass for me.

cole10up avatar Nov 20 '19 18:11 cole10up

Confirmed with @aaemnnosttv that this is expected behavior via SK slack channel. Passed QA ✅

cole10up avatar Nov 20 '19 19:11 cole10up