Anura Docs

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.