# Reference

| Method                                          | Description                                                                       |
| ----------------------------------------------- | --------------------------------------------------------------------------------- |
| [activate](#iadvize.activate-iadvize.logout)    | Activates the tag with an identity. Needed when authentication is enabled.        |
| [get](#iadvize.get)                             | Getters                                                                           |
| [on / off](#iadvize.on-iadvize.off)             | Event listeners                                                                   |
| [help](#iadvize.help)                           | Displays a list of available commands in the console                              |
| [logout](#iadvize.activate-iadvize.logout)      | Removes an identity, effectively stopping the tag when authentication is enabled. |
| navigate                                        | Changes the current screen and restart the tag, allowing a new targeting run      |
| [recordTransaction](#iadvize.recordtransaction) | Records a transaction                                                             |
| [set](#iadvize.set)                             | Setters                                                                           |

## iAdvize.activate / iAdvize.logout <a href="#iadvize.activate-iadvize.logout" id="iadvize.activate-iadvize.logout"></a>

These methods are used for authentication. Please see the dedicated Help Center article : <https://help.iadvize.com/hc/articles/6043078724626>

## iAdvize.get <a href="#iadvize.get" id="iadvize.get"></a>

`iAdvize.get` takes a single property argument, and returns the associated value. Properties are keys that reference values that can change over time. These values can be accessed :

* directly, using `iAdvize.get` (ex: `iAdvize.get('visitor:cookiesConsent')`)
* when they change, using iAdvize.on (ex: `iAdvize.on('visitor:cookiesConsentChange', callback)`)

| Property               | Description                                     | Values                                  |
| ---------------------- | ----------------------------------------------- | --------------------------------------- |
| tag:version            | The tag version                                 | `"LIGHT"`, `"FULL"`                     |
| visitor:cookiesConsent | Whether the visitor consented to cookies or not | `true`, `false`, `null` (default)       |
| visitor:GDPRConsent    | Whether the visitor consented to GDPR or not    | `true`, `false`, `null` (default)       |
| chatbox:status         | The status of the chatbox                       | `OPENED`, `REDUCED`, `CLOSED` (default) |

#### Example :

```javascript
window.iAdvizeInterface = window.iAdvizeInterface || [];
window.iAdvizeInterface.push(function(iAdvize) {
  const visitorCookiesConsent = iAdvize.get('visitor:cookiesConsent');
});
```

## iAdvize.on / iAdvize.off <a href="#iadvize.on-iadvize.off" id="iadvize.on-iadvize.off"></a>

`iAdvize.on` takes two arguments :

* The name of an event,
* A callback that takes the associated event value as parameter.

Every property available on `iAdvize.get` also has a corresponding event (iAdvize.on('{property}Change', (value) => {...})). `iAdvize.off` takes the same arguments to remove the event listener.

#### Example :

```javascript
window.iAdvizeInterface = window.iAdvizeInterface || [];
window.iAdvizeInterface.push(function(iAdvize) {
  iAdvize.on('visitor:cookiesConsentChange', function(visitorCookiesConsent) {
console.log(visitorCookiesConsent);
  });
});
```

## iAdvize.set <a href="#iadvize.set" id="iadvize.set"></a>

Set editable properties.

| Property               | Description                                     | Values          |
| ---------------------- | ----------------------------------------------- | --------------- |
| visitor:cookiesConsent | Whether the visitor consented to cookies or not | `true`, `false` |
| visitor:GDPRConsent    | Whether the visitor consented to GDPR or not    | `true`, `false` |

#### Example :

```javascript
window.iAdvizeInterface = window.iAdvizeInterface || [];
window.iAdvizeInterface.push(function(iAdvize) {
  iAdvize.set('visitor:GDPRConsent', true);
});
```

## iAdvize.help <a href="#iadvize.help" id="iadvize.help"></a>

* Lists all the available methods,
* Lists all the available properties on `get` and `set`,
* Lists all the available events on `on` and `off`.

## iAdvize.recordTransaction <a href="#iadvize.recordtransaction" id="iadvize.recordtransaction"></a>

Allows to record transactions. See the dedicated article on the Help Center: <https://help.iadvize.com/hc/en-gb/articles/206375538>

#### Example :

```javascript
window.iAdvizeInterface = window.iAdvizeInterface || [];
window.iAdvizeInterface.push(function(iAdvize) {
  iAdvize.recordTransaction({
id: 'unique-id',amount: 49.95,
  });
});
```
