Enabling Google AdSense Test Mode

Enabling Google AdSense Test Mode

Wed Dec 20 2017209 words

Why you should test AdSense

Testing is an integral part of building anything and AdSense ads are no different.

When you integrate Google AdSense into your website during development you will need to test them to make sure they render on your page as expected. An issue can occur where reloading your pages during testing can give extra AdSense ad impressions and in turn bloat your AdSense ad performance data leading to skewed statistics. Lucky AdSense provides an option to enable a test mode that does not impact your data.

Enabling AdSense test mode

Add the following to your AdSense code block to enable test mode (dont forget to remove when your ads go live). You could also set this attribute dynamically based on the environment (whether local, testing, or production)

data-ad-test="on"

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
   <!-- MY AD - 01/01/2017 -->
   <ins class="adsbygoogle"
      style="display:block"
      data-ad-test="on"
      data-ad-client="ca-pub-0000000000000000"
      data-ad-slot="0000000000"
      data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

Featured Articles