Displaying Google Ad's Only When Referred From Google

If you are using Google Ad's and only want them to be displayed when the referrer is Google, then you can use this simple javascript if condition to accomplish this.

<div style="text-align:center">
  <script type="text/javascript">
    <!--
      if (document.referrer != null && document.referrer.toString().indexOf("google") != -1)
      {
        google_ad_client = "pub-9087979379036836";
        google_ad_slot = "3579334815";
        google_ad_width = 468;
        google_ad_height = 60;
        document.write("<script type='text/javascript' src='http://pagead2.googlesyndication.com/pagead/show_ads.js'><\/script>");
      }
    //-->
  </script>
</div>

Posted on Dec 15, 2007 by Mike Jennings in Web | 0 Comments | Permalink



Post a Comment:
  • HTML Syntax: Allowed