Anura Docs

Anura Integration Guide

Anura Script is our preferred method as it collects more information on the user, thereby finding more fraud. Anura Script is robust, enabling it to capture and identify more fraud in client campaigns. We encourage all integrations to be connected with Anura Script, wherever possible, to provide the most insight possible to your campaigns.

When technical integrations will not allow for Anura Script, we do offer Anura Direct for a fast, pre-bid analysis of traffic quality. Just as powerful as Anura Script, Anura Direct is ideal for time-sensitive traffic analysis often associated with click and programmatic campaigns. Anura Direct detects suspect and non-suspect traffic, with suspect traffic aligning 100% with Anura Script.

When in doubt, don’t take the lazy way out. Use Anura Script when possible to get the best bang for your buck. Use Anura Direct when you’re in a pinch and need a quick response, or your program will not allow for the use of JavaScript.

Script Integration

Anura Script is our preferred method as it collects more information on the user, thereby finding more fraud. Anura Script is robust, enabling it to capture and identify more fraud in client campaigns. We encourage all integrations to be connected with Anura Script, wherever possible, to provide the most insight possible to your campaigns.

Script Integration - Request

Placing the following JavaScript snippet at the end of your page's <head> tag will allow Anura to obtain data about, and generate a result value for each visitor to your site.

JavaScript
<script type="text/javascript">
(function(){
    var anura = document.createElement('script');
    if ('object' === typeof anura) {
        var params = [];
        var request = {
            instance: yourAssignedInstanceId,
            // source: encodeURIComponent('optionalSourceTrackingId'),
            // campaign: encodeURIComponent('optionalCampaignTrackingId'),
            // exid: encodeURIComponent('optionalUniqueExternalId'),
            // variable: encodeURIComponent('optionalResponseObjectVariable'),
            // callback: encodeURIComponent('optionalCallbackFunction')
        };
        for (var x in request) params.push(x+'='+request[x]);
        params.push(Math.floor(1E12*Math.random()+1));
        anura.type = 'text/javascript';
        anura.async = true;
        anura.src = 'https://script.anura.io/request.js?'+params.join('&');
        var script = document.getElementsByTagName('script')[0];
        script.parentNode.insertBefore(anura, script);
    }
})();
</script>

You also have the option of using a "one line" piece of JavaScript, as some platforms and integrations do not allow the use of full scripts. Please ensure the replacement of example parameter values with their actual values when utilizing the one line script.

JavaScript
<script type="text/javascript" src="https://script.anura.io/request.js?instance={INSTANCE_ID}&source={MACRO}&campaign={MACRO}&{CACHEBUSTER}"></script>

Parameters

Required Type Description Note
instance integer Your instance ID.
Optional Type Description Note
source string A variable, declared by you, to identify "source" traffic within Anura's dashboard interface.
campaign string A subset variable of "source," declared by you, to identify "campaign" traffic within Anura's dashboard interface.
exid string A unique external tracking ID, declared by you, that is used to query the result from Anura's servers.
variable string The variable name of the JavaScript object that response data will be assigned to. This variable contains the response ID, in addition to other data, that will allow you to make real-time decisions.
callback string The name of the JavaScript function to be executed once the response is received. Response data will be passed to the callback function as the first argument.
cachebuster * integer A random multi-digit integer added to the end of the query string to prevent caching of Anura's Script. * The cachebuster value should only be used for "one line" script implimentations

Source, campaign, exid, variable, and callback parameters are limited to a maximum of 128 characters.

Source and campaign parameters may not equal the following values: "all sources", "all campaigns", "&", "*", "?", "%".

Variable and callback parameters are allowed to start with: "$", "_", or "a-z" characters, followed by "a-z" and "0-9" characters.

Security

Anura Script offers an optional "domain locking" feature to protect against unauthorized use of your instance ID. Once enabled, only requests from client authorized domains will be accepted for processing. Please talk to support about enabling the script domain locking feature.

Script Integration - Response

If you want to be proactive and use response data to make decisions within the context of your page, you will need to access the "response" object. The JavaScript example below demonstrates 2 unique methods of how to use the response object to query for a "result" using the response ID or EXID.

JavaScript
<script type="text/javascript">
// method 1: use setInterval to check for the response object every 50 milliseconds
var interval = setInterval(function(){
    if ('object' === typeof optionalResponseObjectVariable) {
        // declare the response object when available
        var response = optionalResponseObjectVariable.getAnura();
        // if the response ID or EXID is available
        if (response.getId() || response.getExId()) {
            // clear defined intervals!
            clearInterval(interval);
            // get the result from Anura servers...
            getResult(response);
        }
    }
}, 50);
// method 2: use a defined callback function
function optionalCallbackFunction(response) {
    // if the response ID or EXID is available
    if (response.getId() || response.getExId()) {
        // get the result from Anura servers...
        getResult(response);
    }
}
// get the result from Anura servers using the response object
function getResult(response) {
    var method = 'POST';
    var params = ['instance=yourAssignedInstanceId'];
    if (response.getId()) params.push('id='+encodeURIComponent(response.getId()));
    if (response.getExId()) params.push('exid='+encodeURIComponent(response.getExId()));
    var url = 'https://script.anura.io/result.json'+('GET' === method ? '?'+params.join('&'): '');
    // internet explorer 8-9
    if (window.XDomainRequest) {
        var http = new XDomainRequest();
        if (http) {
            http.open(method, url);
            http.onprogress = function(){};
            http.ontimeout = function(){};
            http.onerror = function(){};
            http.onload = function(){
                // continue with your custom result handler...
            };
            setTimeout(function(){http.send('POST' === method ? params.join('&'): '');}, 0);
        }
    // other browsers
    } else if (window.XMLHttpRequest) {
        var http = new XMLHttpRequest();
        if (http && 'withCredentials' in http) {
            http.open(method, url, true);
            if ('POST' === method) http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
            http.onreadystatechange = function() {
                // continue with your custom result handler...
            }
            http.send('POST' === method ? params.join('&'): '');
        }
    }
}
</script>

Response Object Functions

Function Description Note
getId() Returns the response ID used to query the result from Anura's servers.
getExId() Returns the self declared unique external tracking ID used to query the result from Anura's servers.
getResult() Returns the result value. Requires full response.
getMobile() Returns whether a mobile device was detected. Requires full response.
getAdBlocker() Returns whether an ad blocker was detected. Requires full response and ad blocker detection.
getRuleSets() Returns an array of detected broken rule sets. Requires full response and rule sets returnability.
getError() Returns an error message if one has been declared.
getObject() Returns an object of all data listed above.

If you do not specify a response variable when making a script request, "optionalResponseObjectVariable" will default to "Anura".

A "full response" is available, which provides result data immediately and without the need to connect to the result endpoint. Talk to support about enabling or disabling the full response feature.

Ad blocker detection may be enabled or disabled per instance. Talk to support about whether having the ad blocker detection feature turned on/off is right for you.

Script Integration - Result

Script result values may be obtained by calling the endpoint directly.

Method URL Note
GET, POST http://script.anura.io/result.json HTTPS recommended

Example Request

PHP
<?php
// define parameters
$params = array();
$params["instance"] = yourAssignedInstanceId;
$params["id"] = "yourResponseId";
// create a query string storage array
$query_string = array();
foreach ($params as $key => $value) $query_string[] = "{$key}=".urlencode($value);
// setup and initialize curl
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://script.anura.io/result.json?".implode("&", $query_string));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// get the result
$curl_response = curl_exec($curl);
// close the curl connection
curl_close($curl);
// continue with your custom result handler...
?>

Parameters

Required Type Description Note
instance integer Your instance ID.
id string The response ID that is used to request the result from Anura's servers.
Optional Type Description Note
exid string The unique external tracking ID, declared by you, that is used to query the result from Anura's servers. Send "exid" instead of "id" when utilizing the exid parameter.

While we strive to have results available within milliseconds, in worst case scenarios, some results may take longer. Therefore, it is okay to perform multiple queries for a response ID that is not found.

Response ID results will be available for 15 minutes and are removed immediately after a successfully query.

Example Response

{
    "result": "bad",
    "mobile": 1,
    "adblocker": 0,
    "rule_sets": [
        "UE",
        "SP"
    ]
}

Result Values

Result Description
good The visitor has passed our tests and appears to be trustworthy.
warning There are aspects about the visitor that raise concerns. However, we can not say for certain they are bad. It is your decision how to interpret this value.
bad The visitor has failed our testing and should be considered untrustworthy.

Please refer to our script result definitions documentation for more information on these values.

Rule Set Values

Result Description
DI Data Integrity
UE User Environment
DC Data Center
TO Traffic Origin
IP IP Integrity
SP Spoofing
WC Web Crawler

The "rule_sets" array requires "rule sets returnability" to be enabled. Talk to support about enabling or disabling the rule sets returnability feature.

Please refer to our rule set definitions documentation for more information on these values.

Direct Integration

Anura Direct is ideal for a fast, pre-bid analysis of time-sensitive traffic often associated with click and programmatic campaigns, detecting "suspect" and "non-suspect" traffic.

Direct Integration - Endpoint

Direct result values may be obtained by calling the endpoint directly.

Method URL Note
GET, POST http://direct.anura.io/direct.json HTTPS recommended

Example Request

PHP
<?php
// define parameters
$params = array();
$params["instance"] = yourAssignedInstanceId;
// $params["source"] = "optionalSourceTrackingId";
// $params["campaign"] = "optionalCampaignTrackingId";
$params["ip"] = "visitorIPAddress";
// $params["ua"] = "optionalVisitorUserAgentString";
// create a query string storage array
$query_string = array();
foreach ($params as $key => $value) $query_string[] = "{$key}=".urlencode($value);
// setup and initialize curl
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://direct.anura.io/direct.json?".implode("&", $query_string));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// get direct method result
$curl_response = curl_exec($curl);
// close the curl connection
curl_close($curl);
// continue with your custom direct method result handler...
?>

Parameters

Required Type Description Note
instance integer Your instance ID.
ip string The IP address of your visitor. IPV6 addresses are also supported.
Optional Type Description Note
source string A variable, declared by you, to identify "source" traffic within Anura's dashboard interface.
campaign string A subset variable of "source," declared by you, to identify "campaign" traffic within Anura's dashboard interface.
ua string The user agent string of your visitor.

Source and campaign parameters are limited to a maximum of 128 characters.

Source and campaign parameters may not equal the following values: "all sources", "all campaigns", "&", "*", "?", "%".

Security

Anura Direct offers an optional "IP address locking" feature to protect against unauthorized use of your instance ID. Once enabled, requests will only be accepted from client authorized IP addresses. Please talk to support about enabling the direct IP address locking feature.

Example Response

{
    "result": "suspect",
    "mobile": null,
    "rule_sets": [
        "IP"
    ]
}

Result Values

Result Description
suspect Based on available data, we have determined the visitor to be suspect.
non-suspect Based on available data, we have determined the visitor to be non-suspect.

Please refer to our direct result definitions documentation for more information on these values.

Rule Set Values

Result Description
UE User Environment
DC Data Center
IP IP Integrity
WC Web Crawler

The "rule_sets" array requires "rule sets returnability" to be enabled. Talk to support about enabling or disabling the rule sets returnability feature.

Please refer to our rule set definitions documentation for more information on these values.