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.


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.

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
is used for normal text 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.
lets the user upload a file. The fieldname for an upload file must be one of userfile0 – userfile9
is used for URL input. The input is client-side validated to only contain valid URLs.
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.


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:

This field must be present
At least one of the following fields must be present
At most one of the following fields must be present
Exactly one of the following fields must be present
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.


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)


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.

Host name of ad server, e.g.
Host name of file server (CDN), should be used for all links to uploaded files
Matching the protocol of the ad request “http” or “https”
Random number, used for cache-busting
Campaign id
Campaign width
Campaign height
Emediate click counter, used e.g. to pass to third party ad servers. Corresponds to using “EASLink=” in HTML creatives.
Emediate click counter. Uses the target URL stored in the creative.
Path to directory on ad server where “common files” are stored, e.g. “/path/to/common/”
Creative id
Content unit id
Used for composed javascript & video playlists: The order number of the content unit in the request.
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
Content unit height
Content unit width
External website id.
Domain name for file hos, e.g. “”
Complete url to file, e.g. “”. Uses https if request was made over https.
First isense category. Not enabled on all systems.
Secondary isense category. Not enabled on all systems.
Whether the campaign was chosen by the revenue optimization engine
Relative path to directory on ad server where uploaded campaign files are stored, e.g. “/path/to/campaign/files/”
http or https, depending on current request
Geotargeting information as reported by Quova. On the form “x-y-z”. (Country code - region code - city code)
Redirect URL, with true impression counter
Emediate section id
Emediate sitenet id
Sitescreen categories. Not enabled on all systems.
Unique impression ID for the request. Not enabled on all systems.


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

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

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


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

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>');
Cxense © 2012 | Support