Global methods and variables

The AB Tasty Tag provides some methods and variables in the global scope of the browser (window).

Global variables

ABTasty

Type: object

The ABTasty object is a JavaScript variable containing all the information generated by the tag. It also contains a copy of the data used by the tag to work. You can find a description of each property of this object here.

Tracking methods

ABTastyClickTracking()

Type: function

The ABTastyClickTracking() function allows you to send an "EVENT" hit with the "Action Tracking" event category.

ABTastyClickTracking(tracking_name[, null, campaign_id]);
Parameter
Type
Description

tracking_name

string

Name of the action tracking. It will be used as "Event Action".

campaign_id

integer

(Optional) The campaign Id from which the action tracking comes.

Second parameter is not used by the tag anymore and is deprecated ; you should always set it to null. Third parameter is not used by the Universal Collect and our reportings.


ABTastyEvent()

:::caution Deprecated function please prefer to use ABTastyClickTracking(). :::

Type: function

The ABTastyEvent() function allows you to send an "EVENT" hit with the "Action Tracking" event category.

ABTastyEvent(tracking_name[, null, campaign_id]);
Parameter
Type
Description

tracking_name

string

Name of the action tracking. It will be used as "Event Action".

campaign_id

integer

(Optional) The campaign Id from which the action tracking comes.

Second parameter is not used by the tag anymore and is deprecated ; you should always set it to null. Third parameter is not used by the Universal Collect and our reportings.


abtasty.send()

Type: function

The abtasty.send() function allows you to send hits to the Universal Collect.

window.abtasty.send(hit_type, hit_parameters[, event]);
Parameter
Type
Description

hit_type

string

Type of the hit to send. Generally hits which are "Custom trackings".

hit_parameters

object

The parameters to send with the hit. Should match and respect the documentation.

event

MouseEvent

(Optional) Data used by "VISITOREVENT" hit to define target properties and cursor position. It's also used by the QA Assistant.


_abtasty.push()

:::caution Deprecated function please prefer to use abtasty.send(). :::

Type: function

The _abtasty.push() function allows you to send 3 specific types of hits to the Universal Collect.

window._abtasty.push(data);
Parameter
Type
Description

data

array

An array containing hit parameters.

data[0]

string

Type of hit you want to send. Accepted values: 'transaction', 'eco' and 'cv'.

data[1]

string

Name of the 'transaction', 'variable ecommerce' or 'custom variable'.

data[2]

string

ID of the 'transaction'. Value of the 'variable ecommerce' or 'custom variable'.

data[3]

float

(Optional) (Only for 'transaction') The total revenue associated with the 'transaction'.

data[4]

integer

(Optional) (Only for 'transaction') Number of items in the 'transaction'.

'transaction' data is transformed as a new transaction hit. 'variable ecommerce' are transformed as an event hit with ec as 'eco'. 'custom variable' are transformed as a segment hit.

Campaign methods

ABTastyStartTest()

Type: function

The ABTastyStartTest() function allows you to activate a campaign on the current page ; campaign should be in play. This function should be used when campaign is set to be "Targeted by events".

window.ABTastyStartTest(campaign_id[, variation_id]);
Parameter
Type
Description

campaign_id

integer

The campaign ID of the campaign you want to start. Shouldn't be a multipage or mastersegment.

variation_id

integer

(Optional) The variation ID you want to start. Should be used in case of QA and debugging only.

:::caution When you use this function the tag does not check the targeting, including the QA parameters. Take extra care when pushing a campaign that is using an event-based targeting into production. :::

Debugging variables

Debugging variables are part of the debug module ; you can find a description and an explanation of how to use them in the dedicated documentation.

Reloading methods

ABTastyReload()

Type: function

The ABTastyReload() function allows you to reload the tag. It means that the tag reverts all the modifications he did, stops all the pending computation and then rechecks the targeting and applies the campaigns if needed.

window.ABTastyReload();

By default the "automatic reload of the framework" is activated and ABTastyReload() is called at each URL change.


ABTastyPageView()

:::caution Deprecated function please prefer to use ABTastyReload(). :::

Type: function

The ABTastyPageView() function allows you to reload the tag. It means that the tag reverts all the modifications he did, stops all the pending computation and then rechecks the targeting and applies the campaigns if needed.

window.ABTastyPageView();

By default the "automatic reload of the framework" is activated and ABTastyPageView() is called at each URL change.

Locking tag execution

Locking tag execution could be useful to avoid issues with modifications that appear too early.

It has been developed to be compatible with SSR websites. You should first use it in a staging/development environment before pushing it into production.

lockABTastyTag

Type: boolean

If the value is equal to true, the tag will stop its execution at the beginning. Meaning that the main process of the tag will not start and campaigns/collect will not process until the unlock.

window.lockABTastyTag

You need to set this variable to true before the tag loads. To unlock the tag please use unlockABTasty() function.


unlockABTasty()

Type: function

The unlockABTasty() function enables you to start the tag in case it was locked with the lockABTastyTag variable.

window.unlockABTasty();

This function is accessible only if the tag is locked thanks to window.lockABTastyTag. You should call the function only when the page is totally rendered.

abtastyGrantConsent

Variable related to consent CustomEvent, detail can be found in JavaScript Events page.

Last updated

Was this helpful?