Tip #33: Avoiding duplicate ads

If you have more than one banner on a website page, it’s easy to ensure that you never show the same banner twice with the OpenX ad server.

Provided you are using Single Page Call, or the Javascript zone tag, the Local Mode zone tag or the XML-RPC zone tag, then under Tag Settings on the Invocation Code tab, you can set the “Don’t show the banner again on the same page” option, and OpenX will ensure that the same banner is not shown more than once on a page.

The "Don't show the banner again on the same page" option.

The "Don't show the banner again on the same page" option.

There is also the “Don’t show a banner from the same campaign again on the same page” option for Single Page Call and these three zone tags, which can be used to ensure that every banner on a page will be from a different campaign.

Of course, you can use both options if you want to ensure that not only is every banner on a page from a different campaign, but also that there are no duplicate banners.

Tip #20: Protect your site from OpenX “hangs”

If you’re a small website publisher, and you run your own OpenX ad server on the same server as your website, then you know that when your server goes down, everything stops. That’s just a fact of life for small website publishers, and there’s not much you can to but get your server back up and running as soon as possible.

However, if you are lucky enough to have seen your site grow up over time, or you work for a company that has a large site, you may be in a position where you run OpenX on a server that is different to the one that runs your website. (If you use the OpenX Hosted service, then you’re in the same situation — OpenX is running on a server that is different to the one that runs your website.)

If this is the case, then there is a possibility that the OpenX ad server system might go down, but your website server will still be up and running.

If this has ever happened to you, then you will know that this matters — and not just because your banners will not display. It can actually be a major issue because if the OpenX ad server is down, then your website may “hang” when it gets to the part of the site where a banner should be displayed1. This is bad news for your users, because they won’t be able to view your website properly.

Below is the complete list of OpenX’s different zone tag types2, and their susceptibility to this problem:

  • Singe Page Call: Susceptible3.
  • Javascript: Susceptible.
  • iframe: Not susceptible.
  • Interstitial or Floating DHTML: Susceptible.
  • Image: Not susceptible.
  • No Cookie Image: Not susceptible.
  • Popup: Susceptible.
  • XML-RPC: Susceptible4.

In all of the above cases, remember, the zone tags that are susceptible will cause your website to hang at the point where the tag is located in your site’s HTML during loading, so that your users won’t be able to see the entire page without some kind of delay. This means that it’s got nothing to do with whether banners load or not, as in all cases, if your OpenX ad server is not responding, you won’t get any banners displayed5.

So, if you have an OpenX ad server in use that doesn’t live on the same server as your website, what can you do to protect yourself from this situation?

Use a tag type that is not susceptible to the hanging page problem

As you may be aware, the Single Page Call and the Javascript zone tags provide advanced features that are not available in other tag types, just as supporting companion positioning, and the ability to avoid duplicating banners, etc. Assuming that you don’t need these features, then simply using the iframe or Image zone tag types makes sense6.

End place tags & position with CSS

Assuming that you would like the advanced features of the Single Page Call or Javascript zone tags, then it is possible to avoid hanging issues by placing the tags at the very end of your page’s HTML, and then positioning the banners on the page via CSS.

For example, here’s how you might place a Single Page Call tag at the end of a page, and position the banner via CSS7:

...

<p>End of HTML page!</p>

<!-- Generated by OpenX 2.8.1 -->
<script type='text/javascript'
  src='http://www.example.com/openx/www/delivery/spcjs.php?id=1'>
</script>

<div style="position: absolute; top: 10px; right: 10px;">
<script type='text/javascript'><!--// <![CDATA[
 /* [id1] Website 1 - Zone 1 */
 OA_show(1);
// ]]> --></script><noscript><a target='_blank'
  href='http://www.example.com/openx/www/delivery/ck.php?n=f1bb21f'>
  <img border='0' alt=''
  src='http://www.example.com/openx/www/delivery/avw.php?zoneid=1&amp;n=f1bb21f'
/></a>
</noscript>
</div>

</body>
</html>

There are many ways of CSS positioning, of course. Use whatever method suits you best!

Disadvantages

It is worth mentioning that is you do decide to use end placement of tags and position with CSS, this means that your banners will be the very last items to load on your web page. This means that you may find that you have a reduced number of impressions, as a result of users “navigating away” from the page before the banners have loaded; this in turn may result in reduced income (either through fewer impressions for CPM campaigns, or through fewer clicks/conversions for CPC/CPA campaigns).

However, this is something you will need to make a judgement call on — is it better to sacrifice a little income to ensure that your users can view your website immediately, albeit without banners, in the event that your external OpenX ad server has a problem; or is it better that if your OpenX ad server goes down, your website is not accessible?

Modify the OpenX tags

Finally, if you really want to get creative, you can modify the OpenX tags. This is for advanced users only, though. Best of luck! :)

  1. How long might your site hang for before the rest of the content loads? This depends on exactly how the OpenX ad server has failed. The worst case, however, is when the server is not responding to requests, in which case most browsers will hang for minutes. []
  2. The Local Mode zone tag is not included as this tag can only be used when OpenX is installed on the same server as the website. []
  3. Additionally, as the Single Page Call tag, by default, recommends that part of the tag code be placed in the HTML document’s <head> section, this will cause the page to hang before any part of your web site has been displayed. []
  4. Results may vary, depending on the implementation language used. With the default PHP-based XML-RPC zone tag, the implementation actually causes the web page to hang at the start of the document, so page loading hangs before any content has been displayed. However, the default tag has a timeout of 15 seconds, which is much shorted than the hanging time for the other tags. []
  5. It also means that in all cases, the user’s browser will not appear to complete loading the page contents, even for the non-susceptible tags — it’s just that even though the browser will keep spinning, trying to load the banners, at least all of the other page content will have loaded for the user to see. []
  6. Remember that the zone tag type can only display image based banners; it can’t display Flash, text and HTML banners, for example. The No Cookie Image zone tag type is another special case, for displaying image based banners in Email/Newsletter zones. []
  7. It’s a contrived example, as you’d probably never use the Single Page Call zone tag for just one zone, but it illustrates the concept []

Tip #14: Troubleshooting banner delivery

Sometimes, users who are new to the OpenX ad server find that they struggle to get OpenX to deliver banners. Even experienced OpenX users can sometimes run into difficulties with banner delivery issues.

As you may imagine, there are may different reasons why OpenX might not be delivering banners, so there is no single solution to this problem. Fortunately, the process of diagnosing OpenX banner delivery problems is not a difficult task! Just walk through the following banner delivery troubleshooting check-list…

#1.0: Are any banners delivering?

Is the OpenX ad server at least delivering some banners (even if they are not the ones you want), or is it delivering no banners at all? If at least some banners are being delivered, move on to item #2.0 in the check-list, otherwise if no banners are being delivered at all, proceed with item #1.1 below.

#1.1: Are you using direct selection?

If you are trying to deliver banners from OpenX using direct selection, instead of by using a zone tag, then try to deliver some banners via zones first. Direct selection is known to be a very complex and difficult process, and is really only intended for advanced users of OpenX. If you’re unable to get banners delivering, chances are you’re not an advanced user just yet — so, try using zone tag delivery instead.

#1.2: Have you re-generated the zone tag?

Sometimes, the reason why banners are not delivering is due to a simple cut & paste error. Try re-generating the zone tag, and cut & paste it into your website again, to see if this helps.

If it doesn’t, try putting the zone tag into a very simple HTML page, with no other content. It might be that there is some kind of conflict between your page’s content and the zone tag. Putting the zone tag into a plain HTML page will allow you to ensure that this is not the case.

#1.3: Have you tried a different zone tag type?

It may be that there is a problem with the zone tag type you have selected, or it may be that the zone tag type you are using is not suitable for the banners you have linked — for example, the Image tag can only display actual image banners; and HTML banner would not be able to be displayed by the Image tag.

Try another zone tag type, and see if that helps. As a general rule, the Javascript zone tag type should work in a plain HTML page, when viewed with a normal web browser.

#1.4: Are you certain there are active banners in the zone with probabilities greater than 0%?

Have you checked the zone probability screen for the zone you are generating the tag for, to ensure that there is at least one active banner linked to the zone with a probability greater than 0%? If there are no such banners, you will need to link some active banners to the zone, so that they can be displayed!

Alternatively, if you are relying on zone chaining to send you to a secondary zone in a case where the zone you have generated the tag for has no active banners, try generating the secondary zone’s tag and using this directly, to see if this helps — perhaps you haven’t got the zone chaining setup as you might expect.

#1.5: Are you certain that there is a “guaranteed delivery” banner in the zone?

Many is the time that The Guru has been called in by a client who is complaining that one of their zones is not displaying any banners, and it has turned out that, for example, all of the banners linked to the zone are limited to only display once per day, and all of the banners have already been seen by the client that day — resulting in there being no banners left in the zone that can possibly be displayed.

As there are many different forms of delivery limitations and/or capping that may result in banners not being displayed, double check that you have at least one “guaranteed delivery” banner linked to your zone, to ensure that at least this banner can be displayed if all others cannot.

#1.6: Are you running an ad blocker?

Ad blockers like Adblock Plus can, rather obviously, prevent banners from showing. If you have an ad blocker installed, try disabling it to see if that helps!

#1.7: Diagnose the web server calls made by the zone tag

If the above steps have not helped, then the chances are that something is going wrong on your web server when the zone tags are called. To try to diagnose what the problem is, you will need to investigate the process of the calls to the web server itself.

As an example, consider this plain HTML page containing nothing but a single OpenX Javascript zone tag in it, running on an OpenX ad server installation on the “www.example.com” domain:

<html>
<head>
  <title>Text OpenX Page</title>
</head>
<body>

<!--/* OpenX Javascript Tag v2.8.0 */-->
<script type='text/javascript'><!--//<![CDATA[
  var m3_u = (location.protocol=='https:'?'https://www.example.com/openx/www/delivery/ajs.php':'http://www.example.com/openx/www/delivery/ajs.php');
  var m3_r = Math.floor(Math.random()*99999999999);
  if (!document.MAX_used) document.MAX_used = ',';
  document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
  document.write ("?zoneid=1");
  document.write ('&amp;cb=' + m3_r);
  if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
  document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
  document.write ("&amp;loc=" + escape(window.location));
  if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
  if (document.context) document.write ("&context=" + escape(document.context));
  if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
  document.write ("'><\/scr"+"ipt>");
//]]>--></script>

</body>
</html>

When a user’s browser sees this code in the page, a number of calls are made to different URLs on your OpenX server. You can actually see these URL calls by using tools like iehttpheaders for Internet Explorer, or LiveHTTPHeaders for Firefox. Here are the URLs that are called when the above page is viewed:

  • http://www.example.com/openx/www/delivery/ajs.php?zoneid=1&cb=15028591281&charset=UTF-8&loc=http%3A//www.example.com/test.html
  • http://www.example.com/openx/www/delivery/ai.php?filename=468×60.gif&contenttype=gif
  • http://www.example.com/openx/www/delivery/lg.php?bannerid=2&campaignid=1&zoneid=1&loc=http%3A%2F%2Fwww.example.com%2Ftest.html&cb=0c9f6849c2

You can probably tell from the above that the first URL called obtains the code required to display the banner, the second URL called obtains the actual banner image, and the third URL called is the call to the 1×1 .gif logging beacon to record the impression after the banner has been displayed. For the purpose of debugging why no banners are being delivered, the first URL called is the most important, as it is the call to get code to display the banner.

Putting the first URL into a browser returns something like the following:

var OX_cacd23fb = '';
OX_cacd23fb += "<"+"a href=\'http://www.example.com/openx/www/delivery/ck.php?oaparams=2__bannerid=2__zoneid=1__cb=b5fcef6ca8__oadest=http%3A%2F%2Fwww.openxtips.com%2F\' target=\'_blank\'><"+"img src=\'http://www.example.com/openx/www/delivery/ai.php?filename=468x60.gif&contenttype=gif\' width=\'468\' height=\'60\' alt=\'\' title=\'\' border=\'0\' /><"+"/a><"+"div id=\'beacon_b5fcef6ca8\' style=\'position: absolute; left: 0px; top: 0px; visibility: hidden;\'><"+"img src=\'http://www.example.com/openx/www/delivery/lg.php?bannerid=2&amp;campaignid=1&amp;zoneid=1&amp;loc=http%3A%2F%2Fwww.example.com%2Ftest.html&amp;cb=b5fcef6ca8\' width=\'0\' height=\'0\' alt=\'\' style=\'width: 0px; height: 0px;\' /><"+"/div>\n";
document.write(OX_cacd23fb);

This is the Javascript that actually writes out the HTML for displaying the banner.

Obviously, the above examples will be different on your OpenX ad server installation, as you won’t be using “www.example.com” as your domain name, you may have OpenX installed in a different path, and you may be using a zone tag that does things in a different way to the Javascript zone tag. However, the basic process is the same — if you view the URL calls being made to your OpenX ad server when you view a simple page containing your zone tag, the first URL called should be the one that, if then called separately in a browser, returns code to produce the banner contents.

If you find that no banner contents are being returned by this call, then something is wrong with your ad server installation that is preventing the banner contents from being returned. Generally, this can be diagnosed by the following steps.

#1.7.1: Check the web server logs

Look at your web server logs, and try to find instances of the URL call that returns the banner contents. These may be in a separate error log from the normal log, if an error is occurring when the URL is called. Your log should help you determine why the call is failing. The two most common reasons for this failing are:

  • An incorrect permission on a file or directory, which is preventing the web server from reading either the OpenX ad server code or one (or more) of the various cache files that are in the OpenX “var/cache” directory; and
  • A problem with your database server (for example, the database server is not running, you have a corrupt table or data in the database, the database user password or permissions have been changed, etc.) is preventing OpenX from reading the required banner information.

#1.7.2: Turn on higher debugging

If the web server logs still don’t help you determine why the URL call that returns the banner contents is failing, you may need to enable a higher level of debugging output to see if this presents you with any additional information. However, be aware that when you do this, debugging errors may appear in your live site, so, this really is a last resort.

To enable higher level debugging, edit your OpenX configuration file, and change the setting:

[debug]
production=1

so that the production value is 0 (or “false”).

You may also need to modify your PHP settings to enable the display of errors.

With luck, these changes should allow you to see some kind of error, which should allow you to either diagnose and fix the issue, or at least submit a detailed bug report for the OpenX team!

#2.0: Some banners are delivering, but not according to expectations.

Sometimes, banners are delivering, but those banners don’t seem to be delivering according to your expectations. For example, it might be the case that:

  • All of the banners you see being delivered are not the banners you thought you would see;
  • There’s a specific banner that you think you should see, but you never seem to actually see it; or
  • There a banner being delivered sometimes that you just don’t expect to see at all.

In these cases, following troubleshooting check-list should help.

#2.1: Are you using the correct zone tag?

Generally, the reason that all of the banners that are appearing in a zone seem to be the wrong banners is because the zone tag is not actually the correct zone tag, often as a result of a cut & paste error from another location on your website.

Try re-generating the tag directly from OpenX, and re-inserting the tag into your site in the desired location.

#2.2: Is a banner you expect to see, but do not see, active and linked?

Double check on the zone probability screen that the banner you are expecting to see is actually active and linked to the zone you are viewing. Double check that the banner has a probability greater than zero!

#2.3: Is a banner you expect to see, but do not see, a recently added or modified banner?

The OpenX ad server employs a caching system to ensure more efficient banner delivery. As a result, changes to banners, including the linking of new banners to zones, will not become active in the delivery engine until the banner cache timeout value has passed.

If the banner you are expecting to see, but are not seeing, has been recently added, linked to a new zone, or in some other way modified, ensure that you have waited until the cache timeout value has passed before checking to see if the banner can now be seen.

#2.4: Is a banner you expect to see, but do not see, targeted and/or capped?

Sometimes, banners that are actually delivered will not be visible by you, as you will have targeted and/or capped the banner delivery in such a way that it is only visible to other users of your website.

Use the zone probability screen to quickly see if a banner is targeted and/or capped, and if so, review the targeting and/or capping to ensure that it is correct. You can also inspect the number of impressions recorded for the banner in the statistics screens, to ensure that banners that you are not able to view yourself are actually being delivered.

#2.5: Are you running any 3rd party ad network banners?

Occasionally, you may see a banner on your site that is unexpected. Often, this happens when you are displaying banners from 3rd party ad network banners, and the ad network introduces a new advertiser, or perhaps even a new format of banner advertising that they were not previously supplying.

Try using a tool like iehttpheaders for Internet Explorer, or LiveHTTPHeaders for Firefox to view the URL call path when such a banner is clicked. This may help you identify which ad network is supplying the unexpected banner.

#2.6: Are you running the OpenX Market?

As of OpenX 2.8.0, the OpenX Market provides a way for publishers to optionally set a base price at the campaign level, so that if there is an advertiser in the OpenX Market who wants to pay more than the base price for an impression, they can, and the OpenX Market advertiser’s banner will be shown instead of the banner from the campaign.

While this is obviously great news for publishers who use OpenX, as it allows them a no-risk way to potentially earn more income, it does mean that whenever an OpenX Market advertiser is willing to pay more than the base price for an impression, an “unexpected” banner may be displayed.

If you see an unexpected banner that is not from a 3rd party ad network, check your campaigns, to see if you have enabled any for the OpenX Market. This may be the (pleasant and cash-earning!) reason why you are seeing a banner you were perhaps not expecting to.

Tip #2: Correctly using Single Page Call

When OpenX version 2.6 was released, the OpenX ad server gained a new feature called Single Page Call. If you’ve got more than one banner on a page, then Single Page Call can be one way to get more performance out of your OpenX installation.

The way OpenX generally works is that for every position on your website that you want to display advertising, you set up what’s called a “zone” in OpenX. For every one of these zones, you then generate the zone’s “zone tag” (sometimes called an “invocation code tag”), and you  put these tags into your page’s HTML source where you want the banners to display.

When your site is viewed, each zone tag in your site’s HTML makes a call off to your OpenX ad server, OpenX figures out what banner to show, and then sends it back, ready for display. So, if you have more than zone on a page, this means that you are going to be making more than one call to your OpenX ad server per page view.

The Single Page Call system, though, means that you can make just the one call off to your OpenX ad server to get all of the banners for the page, no matter how many zones you want to display. Fewer calls means less load on your ad server, and also means faster load times for your website.

You can find more information about generating the Single Page Call tag in the OpenX documentation. (The process in OpenX 2.7-beta is slightly different from that in OpenX 2.6, but unfortunately the OpenX 2.7-beta documentation doesn’t seem to be available from OpenX yet.)

However, what may not be immediately obvious from the OpenX documentation is that because OpenX’s Single Page Call code is generated at the website level, this means that the code will, by default, retrieve a banner for every zone configured in the website.

If you always display all of the zones on every page, then there’s no problem at all; but if you have many zones, and you don’t display every zone on every page, then using the Single Page Call code without modification will have two consequences.

Firstly, as you can probably imagine, the performance of your OpenX installation and your website will suffer. Asking OpenX to decide which banner to display for a given zone, and then having to transfer the banner display code for said banner, when you’re not even going to display it, is somewhat wasteful.

Secondly, if you have configured OpenX to log requests as well as impressions, you will notice that your requests are much higher than your impressions, because you are requesting banners that you then don’t even attempt to display. This often leads to concerns that perhaps there is something wrong with your OpenX installation, or that there is some reason why your impression values are “wrong” — when in fact, there’s nothing wrong at all, other than the fact you’re requesting banners that are never going to be used.

To improve performance, and to ensure that your request logging is correct, The Guru recommends that you use the “Advanced Usage” feature that is on the OpenX Single Page Call documentation. That is, if you are not going to display all of the zones defined for a website, and you are going to use the Single Page Call code, then you should define the OA_zones variable in JavaScript in the HTML header before your first Single Page Call code block, to limit the zones OpenX will request and return banners for.

For example, if your website has 5 zones defined (say they have zone ID values 1 through 5), and you are only going to display zone ID 1 and zone ID 4 on a page, then, you’d put the following code into your HTML header:

<script type='text/javascript'><!--// <![CDATA[
    var OA_zones = {
      'zone1' : 1,
      'zone4' : 4
    };
// ]]> --></script>

This code should be just above the “header script” part of the Single Page Call code, and of course, as per the OpenX documentation, you’ll need to change all of the “OA_show()” calls to match the names defined above — that is, when placing the “ad script” for zone ID 1 into your page, change the “OA_show(1)” to “OA_show(‘zone1′)”, and similarly for the “ad script” code for zone ID 4.

It may take a little bit of effort to implement, but the improved performance and more accurate statistics are well worth the effort.