Version 5.0
AdvertServe User Manual :: v5.0

Custom Targeting - AJAX Code Integration

Original Code

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


<script type="text/javascript">
  var _avp = _avp || [];
  (function() {
    var s = document.createElement('script');
    s.type = 'text/javascript'; s.async = true; s.src = 'http://adserver.example.com/js/libcode3.js';
    var x = document.getElementsByTagName('script')[0];
    x.parentNode.insertBefore(s, x);
  })();
</script>

<div id="avp_zid_7">
  <script type="text/javascript">
    _avp.push({ tagid: 'avp_zid_7', alias: '/', type: 'banner', zid: 7, pid: 0 });
  </script>
</div>

Modified Code

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 datasource 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">
  var _avp = _avp || [];
  (function() {
    var s = document.createElement('script');
    s.type = 'text/javascript'; s.async = true; s.src = 'http://adserver.example.com/js/libcode3.js';
    var x = document.getElementsByTagName('script')[0];
    x.parentNode.insertBefore(s, x);
  })();
</script>

<div id="avp_zid_7">
  <script type="text/javascript">
    _avp.push({ tagid: 'avp_zid_7', alias: '/', type: 'banner', zid: 7, pid: 0, custom1: '12345' });
  </script>
</div>

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