Synchronous Request

Synchronous or Asynchronous?

We give the option to request our Smaato Ad Tag synchronously (as opposed to previously only asynchronously). The following details outline what this means and how this may be useful to you.

What’s the difference between the types of Ad Tag?

Javascript in itself is synchronous and single-threaded. That means that scripts and script contents are not executed in parallel, but sequentially. While there are improvements made to Javascript engines in modern browsers, this basic caveat has remained.

Therefore, “asynchronous javascript describes a way to handle loading and executing additional scripts in a given page’s context without blocking the initial process of loading the page, mostly using callback functions and waiting/handling events.

How may this create issues for me?

As a publisher, asynchronicity of a tag on your own property is a good idea (because your page isn’t prone to being stalled by a delayed ad request). However, especially when it comes to cases using an environment that’s entirely detached from the rest of the page (such as iframes or SDKs), asynchronous tags have shown to “confuse” said environment (e.g., lead to triggered impression beacons without an ad being actually shown). This mostly applies to using the ad tag within a third-party SDK (e.g., MoPub) or an ad server.

To rectify this, set the sync parameter’s value of your ad tag to true (the default is false!).

Callbacks

Use callback to trigger custom events in case Smaato serves an ad or does not serve an ad. For example, you can insert a tracking method that informs you whether an ad was served or not. You can also define a custom passback function in order to fill the impression through a different source.

Example:

function myJSCallBack(status) {
    if (status == "SUCCESS") {
        alert("callback invoked, Ad Delivered");
    } else if (status == "ERROR") {
        alert("callback invoked, No Ad Delivered");
    }
};

Modified: June 11, 2019 at 6:28 pm