Single Page Call – Basic implementation
|This is the second article in a series of 3. You may also enjoy reading:|
In the previous article, I listed the benefits of using the powerful Single Page Call invocation code for integrating the ads into a website. In this article, I’m going to provide some instructions on the easiest but also least efficient way of implementing this technique.
I’m also going to discuss some of the disadvantages of this default implementation. This is not because I want to discourage you from using single page call, but because I want to encourage you to also read the next article in this series that explain how the masters do it.
Where to find Revive Adserver Single Page Call code?
- Log in on your Revive Adserver system like you normally would and go to the “Inventory” tab.
- Next, click the “Websites” link in the left menu column.
- You’ll see your list of existing websites (there might be just one in your case).
- Click the name of the site you need to generate the code for.
- The properties of the site will be displayed, but there is also an often overlooked tab labeled “Invocation Code”, and that’s the one you should click.
- Revive Adserver will now display a screen with various settings and parameters (I will discuss them later), and a “Generate” button.
The position of the “Invocation Code” tab, next to the website properties, is probably the main reason why so few people know about Single Page Call. Traditionally, we all taught ourselves to go to the Zones link, find the zone we were dealing with and go to that zone’s invocation code generation screen. The location in the navigation for the Single Page Call code generation is logical, but unexpected for most people. If only the designers of OpenX v2.8 (the predecessor of Revive Adserver) had thought of putting a reminder in the old place to at least alert people about the new feature!
Now that you’ve found where to find the Single Page Call code, let’s explore what it looks like.
Structure of Revive Adserver Single Page Call Code
When you press the “Generate” button (leaving all the settings at their default values), Revive Adserver will open a new window and display the single page call code there. You will notice that it consists of two distinct components:
- A few lines of code that are supposed to be placed in the ‘head’ section of the webpage
- A few lines of code, repeated for every zone you have, that are supposed to be placed in the ‘body’ section of the webpage.
Single page call code for <head> of web page
The first piece of code, called the “Header Script” by Revive Adserver, actually consists of just one line of active code, and one comment line. For example:
It is recommended to paste the code, without making any changes to it for the time being, just before the closing tag of the ‘head’ section.
Single page call code for <body> of web page
For every zone that you’ve created for the site being worked on here, you will also get a few lines of code, looking like this:
I’ve had to edit this code slightly by inserting a few line breaks to make it fit in the page width of this site, but in general it is recommended to leave the generated code completely unaltered.
This snippet of code needs to go at the exact position in the ‘body’ section of your web page where the ad is supposed to show up.
How Revive Adserver Single Page Call works
When a web browser receives the code and executes it, it will do a call to a program called ‘spc.php’ (spc is short for Single Page Call). The parameter id=x will have a value for x representing the ID of the site that you’ve selected in the earlier step. Revive Adserver will return an ad for every zone that it knows about for the site referenced by x.
This is where the name ‘single page call’ comes from. Instead of doing a separate call for each zone, this code will do a single call for each page, and retrieve all the ads it needs. These ads are stored in the browsers memory for the time being.
When it’s time to display the ad, in the ‘body’ section of your page, the ad is already available in memory of the browser, and will be displayed almost instantly.
Disadvantages of the ‘out of the box’ code
While the standard code that Revive Adserver generates for you will work just fine, there are a few things to keep in mind:
- When you have several zones defined for a site in your Revive Adserver installation, but you’re not using all of those zones on a given page, there is an inefficiency in the default code generated. Revive Adserver will retrieve the ads for all zones and store them in browser memory, even if you don’t really need them.
- The code being generated has a lot of comments and superfluous elements in it. While informative for a web developer, you don’t actually need to paste it all into the web page. The smaller the code of the site, the faster the site as a whole will be.
Next article: how to make Single Page Call even smarter
In the next article in this series, I will discuss several ways to get even more benefit from the Single Page Call technique, by cleverly calling not all zones but just those zones that are actually needed for the page being created.