Ad Code

Ad code (or ad tag) is a piece of JS code that an ad server uses to serve ads. Each zone of every website on your Adserver.Online account has its own ad code. You need to place this code on your website(s) to display ads.

Ad Code Example

<ins class="aso-zone" data-zone="34919"></ins>
<script data-cfasync="false" async src="https://media.aso1.net/js/code.min.js">

This code works asynchronously, so it doesn't block page loading.

Third-party Clicks Tracking

If you need to publish an ad code in some 3rd-party ad system, you could use "data-redirector" parameter to configure click tracking.

You should examine 3rd-party documentation to find needed macros. For example, in Google Ad Manager (GAM), you should use %%CLICK_URL_UNESC%% macros.

<ins class="aso-zone" data-zone="xxx" data-redirector="%%CLICK_URL_UNESC%%"></ins>
<script data-cfasync="false" async src="https://media.aso1.net/js/code.min.js">

Configuration

The codes (all at once) on a page can be configured using a special JS-code script placed in the HEAD section:

<script> 
   var _aso = _aso || {};
   _aso.option1 = true;
   _aso.option2 = false;
</script>

Available options:

  • no_ad_dups – if true, then the same banner won't be displayed on the same page more than once. False by default.
  • no_campaign_dups – if true, then the campaign (any banners of it) won't be displayed on the same page more than once. False by default.
  • cmp – if true, the ad code will try to find the installed consent management platform (CMP) and retrieve the visitor's consent. Applied to GDPR only. False by default.

Please note these parameters will work with the usual ad code only. They will be ignored if you load ads programmatically using JS API (see below).

Custom Attributes

If you need to pass some custom data to the ad-serving engine for custom targeting or other purposes, you should use the following piece of JS-code in the HEAD section:

<script>
var _aso = _aso || {};
_aso.attr = {
tags: ["tag1", "tag2"],
keywords: ["cats", "dogs"],
hb_bid: 10,
gender: "male"
};
</script> 

There are reserved attributes' names: refid, refid1, refid2, refid3, refid4, refid5, refid6, refid7, refid8, refid9. If you pass them, they will become available inside an ad server in the form of placeholders {refid}, {refid1}, {refid2}, {refid3}, {refid4}, {refid5}, {refid6}, {refid7}, {refid8}, {refid9}.

For example:

<script>
var _aso = _aso || {};
_aso.attr = {
refid: "foo",
refid1: "bar"
};
</script> 

Javascript API

Callbacks

Our ad code supports two JS-callbacks. They have to be configured separately for each piece of code.

  • onload – will be called after the ad is shown
  • onempty – will be called in case of no ads

To configure callbacks, you have to change your ad code as shown:

<ins class="aso-zone" data-zone="xxx" data-onload="onloadCallback" data-onempty="onemptyCallback"></ins>

The corresponding JS function has to be defined:

<script>
function onloadCallback(params) {
console.log("Ad loaded:", params);
}

function onemptyCallback(idzone) {
console.log("No ads for zone #", idzone);
}
</script>

NB: callback function name must not contain _ (underscore) character. Only alphanumeric characters are allowed.

Dynamic loading

You can load ads programmatically if a usual ad code is not suitable for you for some reason. For example, if you want to show ads in a single-page application (SPA). 

To do that, you should use _ASO.loadAd function.

The function parameters: HTML Element ID (string), Zone ID (integer), async loading (must be true), and params (array).

Simple usage example:

_ASO.loadAd("el", 34919); /* HTML ID, Zone ID */

Calling with extra parameters:

_ASO.loadAd("el", 34919, true, {
attr: {
tags:["a", "b"],
keywords: ["cars"]
},
onempty: "onEmpty",
onload: "onLoad"
});

Check out the demo at https://adserver.online/demost/js_api.html

Passing parameters through an ad server to a landing page

We have a couple of scripts to help you pass parameters from the URL where ads (banners) are displayed to a landing page on a visitor's click.

1.  UTM labels

Firstly, you should add this snippet to the HEAD section of all the pages on your site:

<script src="https://media.aso1.net/js/tags/utm2attr.js"></script> 

After that, UTM labels will be available inside an ad server in the form of special placeholders. You can insert them into the landing page URL on the ads form.

Placeholders: {refid}, {refid1}, {refid2}, {refid3}, {refid4}.

2. Arbitrary parameters

Firstly, you should add this snippet to the HEAD section of all the pages on your website:

<script type="text/javascript" src="https://media.aso1.net/js/tags/subid2attr.js"></script> 

After that, GET parameters t1 … t10 will become available inside the adserver in the form of special placeholders. You can insert them into the landing page URL on the ads form.

Placeholders: {refid}, {refid1}, {refid2}, {refid3}, {refid4}, {refid5}, {refid6}, {refid7}, {refid8}, {refid9}.

Besides, you can add a special parameter to URL subid_param=xxx, for example, subid_param=subid. In this case, parameters with the names subid1 … subid10 will be extracted from the URL instead of t1 … t10

Please note that statistics are only being collected for the first two parameters (refid, refid1). Therefore, refid2 to refid9 are considered passthrough parameters, so there are no statistics on them.

Google Ad Manager (GAM)

This article explains how to publish our ad codes in Google Ad Manager.

Facebook Instant Articles

https://developers.facebook.com/docs/instant-articles/reference/ad

You should compose a code manually based on this example:

<figure class="op-ad">
  <iframe width="200" height="400">
     <!-- regular invocation code --> 
     <ins class="aso-zone" data-zone="xxx"></ins><script data-cfasync="false" async src="https://media.aso1.net/js/code.min.js"></script>
  </iframe>
</figure>

Google AMP pages

What's AMP page?

AMP code is available on a zone page.

Auto refreshing

Our ad code supports auto-refreshing for banner zones. To enable it, you should set the refresh interval (in seconds) in the Advanced options of a zone.