About _st (Async module)

Prev Next

Once the data activation base script has been loaded into a website, you’re able to use the synchronous framework by calling, for example:

_st.data.getProperty('test').

However, if you want to, for example, add some properties to the framework, while the script hasn't necessarily been loaded yet (due to an asynchronous execution), you can use the _st object to queue commands to our framework.

Example basescript

(function(a,d,e,b,f,c,s){a[b]=a[b]||function(){a[b].q.push(arguments);};

a[b].q=[];c=d.createElement(e);c.async=1;c.src="//tdn.r42tag.com/lib/"+f+".js";

s=d.getElementsByTagName(e)[0];s.parentNode.insertBefore(c,s);})

(window,document,"script","_st", "9999-v1");

// Add additional settings here (optional)

_st('setPageStructure', 'default|structure');

_st('addTagProperty', 'exampleLocal', 'property');

_st('addTagProperties',  {'example': 'property', 'otherExample': property});

_st('addLocalTagProperties',  {'exampleLocal': 'property', 'otherLocalExample': property});

_st("loadTags");

Explanation

Loading the actual script is the last step op the process. Therefore, the given commands are queued and executed from that queue (_st()) after loading the actual script.

The _st() command queue doesn't provide the user with the entire API, though. The available commands to queue are listed below.

Available functions

Function

Arguments

Description

setPageStructure

1 to N: structureElement (string)

Identify the current page; components are used to form a tree structure.

setEnvironment

1: name (string)

Select the environment to use in tag-loading, defaults to “prod.”

addTagProperty

1: name (string), 2: value (string)

Add a property to the current tag-set; the property will be forwarded to the remote system.

addLocalTagProperty

1: name (string), 2: value (any)

Add a property to the current tag-set; the property will be kept locally in the browser.

addTagProperties

1: propertyObject (object)

Add all object fields as properties to the current tag-set; the properties will be forwarded to the remote system.

addLocalTagProperties

1: propertyObject (object)

Add all object fields as properties to the current tag-set; the properties will be kept locally in the browser.

loadTags

N/A

Call the remote servers and load all configured tags.

resetTag

N/A

Reset the page-structure and all previously configured properties.

setCookieDomain

1: string

Set the default cookie domain for all Relay42 cookies (starting with _sv)

setDataCookieTtl

1: string

Set the default cookie TTL (time to live) for all Relay42 cookies (starting with _sv) in days. The default is 730 days.

setDebug

N/A

Function to set a debug message for a tag that’s not executed due to a selection rule or journey rule

addInitCallback

1: propertyObject (object)

Functions to pass settings

Additional functions (data tracking)

Function

Arguments

Description

setEngagement

1: true/false (boolean)

When an engagement has been set (true), the engagement and all its additional data will be triggered by a 'trackPageView' or 'trackInPageEvent'.

setEngagementType

1: name (string)

The engagement type is defined in the 'configuration' tab

setEngagementContent

1: content (any)

Add content to the current engagement.

addCustomProperty

1: name (string), 2: value (any)

Add a property to the engagement.

resetEventSettings

-

-

trackInPageEvent

-

-

setConversion

1: true (boolean)

When a conversion has been set (true), the conversion and all its additional data will be triggered by a 'trackPageView' or 'trackInPageEvent'.

setTransactionId

1: transactionId (string)

To identify unique conversions

setConversionValue

1: value (double)

Keep track of the value of conversions

addConversionProduct

1: product identifier (string)

Keep track of number of products

setSharedPermissionKey

1: key identifier (string)

The key under which shared permission is saved to the server. This can be used while using cross-domain. Please refer to support for further information

Examples

setEnvironment

Select the environment to use in tag-loading, defaults to “prod”.

_st('setEnvironment', 'test');

setPageStructure

Identify the current page, components are used to form a tree structure.

_st('setPageStructure', 'default|structure');

You can also use the following format:

st('setPageStructure', 'default', 'structure');

setDefaultPageStructure

Identify the fallback structure for the current page, components are used to form a tree structure.

_st('setDefaultPageStructure', 'default|structure');

setStructurePrefix

Set a prefix for the pagestructure which prepended to the configured structure.

_st('setStructurePrefix', 'special');

addTagProperty

Add a property to the current tag-set, the property will be forwarded to the remote system.

_st('addTagProperty', 'example', 'property');

addLocalTagProperty

Add a property to the current tag-set, the property will be kept locally in the browser.

_st('addTagProperty', 'exampleLocal', 'property');

addTagProperties

Add all object fields as properties to the current tag-set; the properties will be forwarded to the remote system.

_st('addTagProperties',  {'example': 'property', 'otherExample': property});

addLocalTagProperties

Add all object fields as properties to the current tag-set; the properties will be kept locally in the browser.

_st('addLocalTagProperties',  {'exampleLocal': 'property', 'otherLocalExample': property});

resetTags

Reset the page-structure and all previously configured properties.

_st('resetTags');

addLocalTagProperties

Add all object fields as properties to the current tag-set; the properties will be kept locally in the browser.

_st('addTagProperty', 'example', 'property');

loadTags

Activate the loading of the tags based on the settings added at this moment.

_st('loadTags');

loadTags (shorthand 1)

The same as the normal loadTags but with adding the page structure directly to the call.

_st('loadTags', 'homepage', 'product');

loadTags (shorthand 2)

The same as the normal loadTags but with adding the page structure and a set of normal tagProperties directly to the call.

_st('loadTags', 'homepage|product|details', {country:'be', language:'nl'});