• Jozef Jarosciak
Jozef Jarosciak Blog

Strive not to be a success, but rather to be of value.

How to test Google Adsense in DEV and UAT environment?

October 8, 2016by joe0

Testing of Adsense server in development is tricky, as it’s against Google’s TOS to click on any of your own ads. In any case, UI developers need to see the ad units in order to properly setup layouts and this is how you can enable Adsense and make ad units visible in your localhost testing environment.

For an Asynchronous Adsense setup, you option: data-ad-test=”on”, such as shows in this example:

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

For a Synchronous Adsense setup, you option: google_adtest = “on”; , such as shows in this example (make sure semicolon is present)

<script type="text/javascript"> google_ad_client = "ca-pub-XXXXXXXXXX"; google_ad_slot = "XXXXXXXXXX"; google_ad_width = 336; google_ad_height = 280; google_adtest = “on”; </script> <!-- YOUR SITE NAME --> <script type="text/javascript" src="//pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

If above doesn’t work, other way of fixing the issue is pretending that domain googlesyndication.com sits on your local testing server, and that can be done by editing your host file in windows (typically in C:\Windows\System32\drivers\etc\hosts)

I hope this helps.

 

Facebook Comments
Posted in: Software DevelopmentTagged: adsense, javascript
  • Jozef Jarosciak – About Me

Site Search

Categories

  • Cloud & Big Data (60)
  • Databases (26)
  • Information Technology (44)
  • Operating Systems (86)
  • Slovak Language Posts (50)
  • Software Development (114)
  • Uncategorized Posts (65)

Links

  • 0. ToolBox
  • 1. FB Comments
  • Bananagrams Solver
  • Block Puzzle Solver
  • Canadian Mortgage Calculator
  • ETX.ca
  • ScrabbleDB.com
  • TryToBreak.com
  • Usenet Archives

Copyright © 2021 Jozef Jarosciak Blog.

Omega WordPress Theme by ThemeHall

sponsored