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.
Great post. We have a few sites using the advanced single page call method, but didn’t realize that calling zones from the server which weren’t on the page would still cause the server to send back information on the undisplayed zone. We’ll have to modify our server-side scripts so this is accounted for. Also didn’t realize OpenX could log requests! That should make calculating inventory a bit easier!
I had a question. With the single page call, is it possible to pass different source variables per zone rather than the entire page? For example, Let’s say I have two leaderboards, one on the top and one on the bottom. How could I differentiate those without creating two zones? Or is it not such a big deal to create the zones.
To the best of my knowledge, it’s not possible to have different source variables for different zones when you are calling the zones via Single Page Call.
That means if you really need different source parameters, you will have to use the normal Javascript Tag, or pass in multiple source values (e.g. source=foo|bar) and setup your delivery limitations to work by “matching” the source value, rather than being “equal” to the source value….
[...] 单页面调用代码只向OpenX请求一次来获取一个页面上所有广告为对应的广告。默认来说,单页面调用代码会选择该网站下所有的广告位对应的广告。所以,如果在页面上如果只显示几个广告位,那最好在代码使用前预先定义,来避免广告被选择了但却没有别显示出来。 [...]