Serverside templates


A template consists of four different sections, fields, required, rules and output. Only fields and output are necessary to specify a template.

Each section starts with the name of the section inside square brackets, e.g. [fields]. Then follows a number of lines with section definitions.

Template files are stored on the ad servers, and the output is generated dynamically every time a creative using a template is fetched.

If the [output] section is changed, all creatives using this template will be automatically updated.

If [fields] or [rules] are changed, creatives using this template will need to be edited first for the changes to take place. In the next system push, changes will be propagated to the ad servers.

This page describes an obsolete method of creating server-side templates, please use the new template system instead.
Serverside templates must be approved and added by Emediate. Before submitting templates to Emediate developers are urged to use our Template Testing Tool to verify that the template syntax is correct and that it generates the expected output.


[fields]

The fields section contains a list of input fields that will be shown to the user. Each field is defined on one line, and consists of a tab separated list of values:

fieldname   TAB  helpfile   TAB   label   TAB  type

fieldname is the name of the variable that will contain the user inputed data

helpfile is either “-” for no help file, or the name of a file located in the help directory (e.g.“clickTag”).

label is the explaining text label that will be shown to the user (e.g. “Upload HTML file”)

type is the type of the field.

choice
allows the user to select one from a given list of values.
The alternatives are given as a tab separated values after the choice keyword.
e.g. choice yes no
string
is used for normal text input
input
is used for normal text input, just like string. The difference is in the generated HTML code: It will be shown on the same HTML table row as the next field, and is shown instead of the label. The value given as “label” for an input field will be used as a default value for the field. An example of an input field is “clickTAG” in the Flash template.
upload
lets the user upload a file. The fieldname for an upload file must be one of userfile0 – userfile9
url
is used for URL input. The input is client-side validated to only contain valid URLs.
flashurl
is used for URL input, where the URL is going to be used as parameters to a flash file. The input is client-side validated to only contain valid URLs. Any ampersands (&) are automatically replaced by %26 by a client-side JavaScript.
There can be no line breaks in a field definition.

You need the field

name TAB - TAB Creative name TAB string

in order to be able to rename your creatives. Without this field, all your creatives will be named after the template name.

The template tool will automatically add this field.


[required]

This section contains a list of requirements, specifying which fields have to contain data. Each requirement is specified on one line of the template source file and consists of a tab separated list of values:

type   TAB   error message   TAB   field list

type is one of:

simple
This field must be present
minone
At least one of the following fields must be present
maxone
At most one of the following fields must be present
either
Exactly one of the following fields must be present
all
If either of the following fields is present, all of the others must be as well
Error message is printed to the user if the requirement isn’t met. Field list contains a tab separated list of fields for the current requirement – one field for the simple rule, at least two fields for the others. There can be no line breaks in a requirement definition.


[rules]

A list of definitions, on the syntax

if (expression) variable = definition

or the unconditional version

variable = definition

There can be no line breaks in a rule definition.

An expression can be one of the following:

def name
True if the variable “name” has been defined
name == value
True if the variable “name” can be expanded to “value”.
not expression
True if the expression is false
expression and expression
True if both expressions are true
If the expression is true, the variable will be set to contain the expanded text from the definition.

The precedence of the expression operators are as following:
and is evaluated first, followed by not, ==, and finally def. Expressions can be nested, but remember the precedence rules!

Spaces after or around the operators are mandatory: use

if (name == Emediate)

not

if (name==Emediate)

The value of a variable is accessed by using EASName{variable name}, e.g. EASName{userfile0}. This can be used in the right hand side of the equality operator (“==”) and in the definitions.

If the value in an equality comparison (“==”) needs to contain spaces, enclose the value in double quotes (””).

A definition is a text string which can contain references to other variables defined earlier in the template, either by user input (from the [fields] section) or by an earlier rule.

There are a number of predefined system variables, also accessed by EASName{variable name}. These have priority over user defined variables. If you want to use these variables, you do not need to add them to the [fields] definition - they are available automatically.

adserver
Host name of ad server, e.g. ad1.emediate.dk
filehost
Host name of file server (CDN), should be used for all links to uploaded files
protocol
Matching the protocol of the ad request “http” or “https”
cachebuster
Random number, used for cache-busting
camp_id
Campaign id
camp_width
Campaign width
camp_height
Campaign height
clickcount
Emediate click counter, used e.g. to pass to third party ad servers. Corresponds to using “EASLink=” in HTML creatives.
clicktracking
Emediate click counter. Uses the target URL stored in the creative.
common_files
Path to directory on ad server where “common files” are stored, e.g. “/path/to/common/”
cre_id
Creative id
cu_id
Content unit id
cu_nr
Used for composed javascript & video playlists: The order number of the content unit in the request.
Example:
eas?EAScus=1,1,3,4,5
cu id and cu nr will be, from left to right:
id=1, nr=0
id=1, nr=1
id=3, nr=2
id=4, nr=3
id=5, nr=4
cu_height
Content unit height
cu_width
Content unit width
ext_site_id
External website id.
filehost
Domain name for file hos, e.g. “cdn.emediate.eu”
full_path
Complete url to file, e.g. “http://cdn.emediate.eu/1/2/3/”. Uses https if request was made over https.
isense_primary
First isense category. Not enabled on all systems.
isense_secondary
Secondary isense category. Not enabled on all systems.
optimize_type
Whether the campaign was chosen by the revenue optimization engine
path
Relative path to directory on ad server where uploaded campaign files are stored, e.g. “/path/to/campaign/files/”
protocol
http or https, depending on current request
region
Geotargeting information as reported by Quova. On the form “x-y-z”. (Country code - region code - city code)
redir
Redirect URL, with true impression counter
site_id
Emediate section id
sitenet_id
Emediate sitenet id
sitescreen
Sitescreen categories. Not enabled on all systems.
uuid
Unique impression ID for the request. Not enabled on all systems.

[output]

This section contains the actual campaign output. It is defined to return Javascript code – if the format flag “js=y” isn't specified, the adserver will add wrapping <script type=””text/javascript”> .. </script> tags around the output.

The output section can contain references to user defined variables and system variables as described in the [rules] section.

Example template
Simple image template

[fields]
name      - Name of creative string
userfile0 - Upload image here upload
gif       - ...or specify a GIF url url
targ      - Link target choice _blank _parent _top
link      - Click URL url

[required]
simple You must specify a click URL link
maxone Either upload an image or specify a gif URL userfile0 gif

[rules]

if (def gif) img_src = EASName{gif}
if (def userfile0) img_src=EASName{path}EASName{userfile0}

[output]
document.writeln('<p>This is an example clickable image:<br/>');
document.writeln('<a href="EASName{clickcount}EASName{link}" target="EASName{targ}">');
document.writeln('<img src="EASName{img_src}" border="0" width="EASName{camp_width}" height="EASName{camp_height}"></a>');
document.writeln('</p>');
Cxense © 2012 | Support