Is Google adsense available for localhost?

thomson picture thomson · Nov 11, 2014 · Viewed 30.7k times · Source

Is it possible to run google adsense ads on a local server as a try out for a example application? I want to implement Google adsense ads in my web application which is running on a localost befor implementing in a live website. If possible then please suggest me the way.

Thank you.

Answer

Alexander Trust picture Alexander Trust · Dec 21, 2015

Yes it is possible (as of 2015). There is a special parameter, to use Adsense on Localhost without risks.

Today the AdSense code is different. If you want to add the adtest-parameter use data-adtest="on" within an ins block. Here is an example code:

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- XYZ 336 x 280 -->
<ins class="adsbygoogle"
 style="display:inline-block;width:336px;height:280px"
 data-ad-client="ca-pub-XXXXXXXXXXXXX"
 data-adtest="on"
 data-ad-slot="XXXXXXXXXXX"></ins>
<script>
  (adsbygoogle = window.adsbygoogle || []).push({});
</script>

Found this on Google AdManager Help:

It shows a basic tutorial on how to achieve this.

Test Ad Exchange tags without charging advertisers or recording clicks and impressions

Add the google_adtest = on; parameter to your ad tag to specify that this is a test implementation. Make sure you set this parameter to "on" to ensure that clicks and impressions aren't recorded and advertisers aren't charged. The default value is "off".