For Google Adsense Publishers : Random Ads Position Script

6 replies
  • SEO
  • |
Dear warrior and Google Adsense publishers,
I would like to share this simple script. With this script you can show up your Google Adsense ads or any other ads randomly : float left or float right around the article..

Hope this will be useful..
Google Adsense Random Ads Position or Placement Code :
Code:
<SCRIPT type="text/javascript">
// begin BloggerCeria GA Trik
var jumlah_iklan = 2;
var waktu_sekarang = new Date()
var detik = waktu_sekarang.getSeconds()
var pasang_iklan = detik % jumlah_iklan;
pasang_iklan +=1;
if (pasang_iklan==1) {
alg="float: left; margin-left: 3px; margin-right: 5px;";
}
if (pasang_iklan==2) {
alg="float: right; margin-left: 5px; margin-right: 3px;";
}
document.write('<div style=\"' + alg + '\">');
// End -->
</SCRIPT>

INSERT YOUR GOOGLE ADSENSE CODE OR OTHER ADS SCRIPT HERE

<SCRIPT type="text/javascript">
document.write('</div>');
</SCRIPT>
You can modify the code in blue color to fit your template.. If you are using Wordpress, then insert the code above on the single.php file. I don't know if the code is allowed by Adsense TOS, use at your own risk..

Some screenshot :


Refresh (F5) the page, the ads will be move the the left..



If I did something wrong or open this thread at the wrong place please forgive me. Just want to share. Thanks!
#ads #adsense #adsense tips #adsense trick #google #google adsense #position #publishers #random #random ads script #script
  • Profile picture of the author jefkas
    A much easier way is just to wrap your adsense code in a div like so:

    Code:
    <div style="float: right; margin:10px;">
    your adsense code
    </div>
    {{ DiscussionBoard.errors[3997427].message }}
  • Profile picture of the author PHDLover
    hi jefkas, yes you can use the div like the one you quote.
    but my script will place the ads randomly everytime visitor open a post or article, floating left or floating right.. see the screenshot..
    {{ DiscussionBoard.errors[4002657].message }}
  • Profile picture of the author PHDLover
    an update for this script..
    you can also replace this code
    Code:
    if (pasang_iklan==1) {
    alg="float: left; margin-left: 3px; margin-right: 5px;";
    }
    if (pasang_iklan==2) {
    alg="float: right; margin-left: 5px; margin-right: 3px;";
    }
    document.write('<div style="' + alg + '">');
    with
    Code:
    if (pasang_iklan==1) {
    stl="adsstyle1";
    }
    if (pasang_iklan==2) {
    stl="adsstyle2";
    }
    document.write('<div class="' + stl + '">');
    then add this into your css file

    Code:
    .adsstyle1 { ANYTHING }
    .adsstyle2 { ANYTHING }
    replace ANYTHING with, well, anything.. such as float right, float left or float center..
    {{ DiscussionBoard.errors[4088490].message }}
  • Profile picture of the author yukon
    Banned
    It would be a way better idea to rotate Adsense Ads server side with php. That way your page html source code wouldn't show any extra javascript.

    Php would only show the exact copy & paste Adsense code from your Adsense Admin in the html source code, If Google ever had a look.

    Every bit of that javascript will show up in your html source code.

    Just saying...
    {{ DiscussionBoard.errors[4088615].message }}
    • Profile picture of the author paulgl
      Wouldn't calling the script from another page work as well, as
      far as hiding the code?

      Just put the code on a separate page by itself, then call it.

      <script type="text/javascript" src="http://where-ever-the-code-is.js">
      </script>

      If you are just shifting it left, right, I probably would want it
      in a set position myself.

      Of course, one could write a little script that changes the word
      left to right at random, then no need for the external javascript.

      Paul
      Signature

      If you were disappointed in your results today, lower your standards tomorrow.

      {{ DiscussionBoard.errors[4088986].message }}
      • Profile picture of the author PHDLover
        Originally Posted by yukon View Post

        It would be a way better idea to rotate Adsense Ads server side with php. That way your page html source code wouldn't show any extra javascript.

        Php would only show the exact copy & paste Adsense code from your Adsense Admin in the html source code, If Google ever had a look.

        Every bit of that javascript will show up in your html source code.

        Just saying...
        you are very right! thanks sir..


        Originally Posted by paulgl View Post

        Wouldn't calling the script from another page work as well, as
        far as hiding the code?

        Just put the code on a separate page by itself, then call it.

        <script type="text/javascript" src="http://where-ever-the-code-is.js">
        </script>

        If you are just shifting it left, right, I probably would want it
        in a set position myself.

        Of course, one could write a little script that changes the word
        left to right at random, then no need for the external javascript.

        Paul
        yup, but I'll stick to Yukon advice..
        {{ DiscussionBoard.errors[4116828].message }}

Trending Topics