Version 5.0
AdvertServe User Manual :: v5.0

Custom Targeting - HTML Code Integration

Original Code

You should now have a generated HTML zone code from the code wizard that looks like the following:


<script type="text/javascript">
document.write('<scr'+'ipt src="http://adserver.example.com/servlet/view/banner/javascript/zone?zid=123&pid=0&random='+Math.floor(89999999*Math.random()+10000000)+'&millis='+new Date().getTime()+'&referrer='+encodeURIComponent((window!=top&&window.location.ancestorOrigins)?window.location.ancestorOrigins[window.location.ancestorOrigins.length-1]:document.location)+'" type="text/javascript"></scr'+'ipt>');
</script>

Modified Code

Within that code, you'll notice that it contains a URL that points to the ad server and it has several parameters. This will be similar for other HTML code formats as well. Look for <IFRAME>, <A> and <IMG> tags containing URLs if the code you have looks different.

What you need to do is add extra parameters for each of your custom fields. When one of your web pages is served, you'll need to output the data into the values of those parameters. Where that data actually comes from is of no concern to the ad server, so you're free to use any data source you have available for use such as but not limited to a cookie, flat file, database record, or a user session object.

Lets look at an example of the above code modified to pass the value 12345 using Custom Field #1 for the custom field.


<script type="text/javascript">
document.write('<scr'+'ipt src="http://adserver.example.com/servlet/view/banner/javascript/zone?zid=123&pid=0&custom1=12345&random='+Math.floor(89999999*Math.random()+10000000)+'&millis='+new Date().getTime()+'&referrer='+encodeURIComponent((window!=top&&window.location.ancestorOrigins)?window.location.ancestorOrigins[window.location.ancestorOrigins.length-1]:document.location)+'" type="text/javascript"></scr'+'ipt>');
</script>

Passing multiple values can be done by delimiting them with commas: 123,456,789 requiring only one in the set to yield a match.

Tip Tip

You should always URL encode the parameter values to ensure that the ad server interprets your data correctly.

Warning Warning

It is extremely important that the custom1 through custom10 parameters be added before the referrer parameter as shown in the example above. The ad server may misinterpret the referring page if it is not the last parameter. This is due to the fact that the ad server uses methods not standard to the HTTP URL specification to parse parameters in an effort to be compatible with third party ad servers that do not properly URL encode their tracking URLs.

Note Note

Even if you have renamed your custom fields by going to Settings > Basic > Custom Fields, the parameter names inserted into the zone code must always be named custom1 through custom10 as your customized field names are only displayed in the user interface and statistics reports.