# 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](/client-side/tag/tag-window-abtasty.md).

### Tracking methods

**`ABTastyClickTracking()`**

> Type: function

The `ABTastyClickTracking()` function allows you to send an ["EVENT"](/client-side/data-apis/universal-collect/uc-hits.md#event) hit with the **"Action Tracking"** event category.

```javascript
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`.*\
\&#xNAN;*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"](/client-side/data-apis/universal-collect/uc-hits.md#event) hit with the **"Action Tracking"** event category.

```javascript
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`.*\
\&#xNAN;*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](/client-side/data-apis/universal-collect/uc-hits.md) to the Universal Collect.

```javascript
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](/client-side/data-apis/universal-collect/uc-hits.md) to the Universal Collect.

```javascript
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*](/client-side/data-apis/universal-collect/uc-hits.md#transaction)*.*\
\&#xNAN;*'variable ecommerce' are transformed as an* [*event hit*](/client-side/data-apis/universal-collect/uc-hits.md#event) *with `ec` as 'eco'.*\
\&#xNAN;*'custom variable' are transformed as a* [*segment hit*](/client-side/data-apis/universal-collect/uc-hits.md#segment)*.*

### 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".

```javascript
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](/client-side/tag/tag-debug-module.md).

### 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.

```javascript
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.

```javascript
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.*\
\&#xNAN;*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.

```javascript
window.lockABTastyTag
```

*You need to set this variable to `true` before the tag loads.*\
\&#xNAN;*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.

```javascript
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.*

### Consent variable

**`abtastyGrantConsent`**

Variable related to consent CustomEvent, detail can be found in [JavaScript Events page](/client-side/tag/tag-javascript-events.md#additional-consent-variable).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.abtasty.com/client-side/tag/tag-methods-variables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
