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>