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.

<script type="text/javascript">
    var anura = document.createElement('script');
    if ('object' === typeof anura) {
        var request = {
            instance: yourAssignedInstanceId,
            // source: 'optionalSourceTrackingId',
            // campaign: 'optionalCampaignTrackingId',
            // exid: 'optionalSingleUseExternalId',
            // additional: 'optionalAdditionalData',
            // variable: 'optionalResponseObjectVariable',
            // callback: 'optionalCallbackFunction'
        var params = [];
        for (var x in request) params.push(x+'='+encodeURIComponent(request[x]));
        anura.type = 'text/javascript';
        anura.async = true;
        anura.src = ''+params.join('&');
        var script = document.getElementsByTagName('script')[0];
        script.parentNode.insertBefore(anura, 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.

<script type="text/javascript" src="{INSTANCE_ID}&source={MACRO}&campaign={MACRO}&{CACHEBUSTER}"></script>

Parameter string values should always be URL encoded when using a "one line" integration.


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 single use external ID, declared by you, that is used to query a specific result from Anura's servers.
additional string An array of Additional Data declared as a JSON encoded string. Read more about using Additional Data.
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.


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.