Using Globule with Google-AdSense

Introduction

Being a replica server becomes more attractive when there is a more direct benefit for helping an origin server out. If the origin owner of a web-site offers the proceeds of the advertisements on his site to the replica's server owner in return for the replica server delivering pages.

Google has developed Adsense, a method where advertisements can be added to web-pages. Whenever a page is requested by a browsing user, then Google provides an advertisement, and accredites awards to the web-site owner.
Here we explain how, instead of always the owner of the web-site you can accredit the proceeds of the advertisements to the owner of the server which serves the page.

First, both web-site owner and replica server owner should obtain an account for Google AdSense. Or if a replica-server does not wants advertisement proceeds he can choose either to let the origin server keep the proceeds or

For the web-site owner / origin server:

The web-site owner should of course include the appropriate AdSense HTML/JavaScript in his pages. However this code should be a bit different from the default HTML snippet as AdSense provides. To allow the proceeds to be shared, Adsense would normally propose to insert something like:

in your HTML. To use AdSense with Globule proceeds sharing then you should change this.

  • Within the <HEAD>...</HEAD> section a similar part as above indicating the default AdSense identity of the web-site owner:
      <script language="JavaScript"><!--
        google_ad_client = "pub-5345587347057115";
        google_ad_width = 468;
        google_ad_height = 60;
        google_ad_format = "468x60_as";
        google_ad_type = "text_image";
        google_ad_chanel = "";
      // --></script>
    
    You can modify this to your own advertisement customization. Note however that this does not actually specify an advertisement to be placed.
  • Below this, verbatimly add:
      <script language="JavaScript" src="http://pagead2.googlesyndication.com/pagead/google_adsense_script.js"></script>
      <script language="javascript" /><!--
        // This should not be placed inside a seperate .js file!
        var globule = new Array();
        var match, key, val, offset, end, items;
        if(document.cookie.length > 0 &&
           (offset = document.cookie.indexOf("GLOBULETRACE=")) != -1) {
          offset += "GLOBULETRACE=".length;
          if((end = document.cookie.indexOf(";", offset)) == -1)
            end = document.cookie.length;
          if(document.cookie.indexOf("\"") == offset) {
            offset += 1;
            end -= 1;
          }
          items = unescape(document.cookie.substring(offset,end)).split(",+");
          for(var i=0; i<items.length; i++) {
            if((match = /(\w+)\((\".*)/.exec(items[i]))) {
              key = match[1];
              val = match[2];
              while(i<items.length && !(match = /(\"[^\"]*)\"\)/.exec(val))) {
                val = val + ",+" + items[++i];
              }
              if(match = /\"([^\"]*)\"/.exec(val))
                val = match[1];
              while((pos = val.indexOf("+")) > -1) {
                val=""+(val.substring(0,pos)+" "+val.substring(pos+1,val.length));
              }
              globule[key] = val;
            } else if((match = /(\w+)\(([^\)]+)\)/.exec(items[i]))) {
              globule[match[1]] = match[2];
            } else
              globule[items[i]] = 1;
          }
          if(globule["servedby"] != "") {
            if(globule["servedby"]=="-" || globule["servedby"].match("pub-[0-9]*"))
              google_ad_client = globule["servedby"];
          }
        } else {
          globule["globule"] = 0;
        }
        function globule_googlead() {
          if(google_ad_client == "" || google_ad_client == "-")
            document.write('<img src="/globuleadm/adnonsense.png">');
          else
            document.write('<script language="JavaScript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></'+'script>');
        }
      // --></script>
    
  • At a point where you want an advertisement put:
    <script language="JavaScript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
    
    Note that at this point, the google_adsense_id should not be set. An alternative for the above code is to use:
    <script language="JavaScript"><!--
      globule_googlead(); // --></script>
    <noscript><img src="/globuleadm/adnonsense.png"></noscript>
    
    Which allows replica server to suppress the ad, when the AdSense id is set to - (a single hyphen).

Furthermore, origin site owners should also follow the description for replica servers, but insert this in the exporting section.

For replica server owners:

Use the FancyServerName directive to set your own Google AdSense identification. This FancyServerName can be set on each separate web-site. If you have a replica server which for the site www.revolutionware.net and your Google AdSense identification is pub-5345587347057115 then you would add:

<VirtualHost *>
  ServerName replica.revolutionware.net
  ServerAlias www.revolutionware.net
  FancyserverName "pub-5345587347057115"
  GlobuleReplicaFor http://origin.revolutionware.net/  geheim
</VirtualHost>

Showcase:

This page shows the ad:

Here is another, more sophisticated way: