# Apps Flyer

{% hint style="info" %}
You'll need to import the javascript file in your website before starting from this [link](https://docs.webtonative.com/javascript-apis/getting-started).
{% endhint %}

{% stepper %}
{% step %}

### setCustomerUserId(userId)

To Set Custom User Id

{% tabs %}
{% tab title="Plain JS" %}

```javascript
const { appsflyer: AppsFlyer } = window.WTN

AppsFlyer.setCustomerUserId("CUSTOM_USER_ID")
```

{% endtab %}

{% tab title="ES 6+" %}

```javascript
import { setCustomerUserId } from "webtonative/AppsFlyer"

setCustomerUserId("CUSTOM_USER_ID")
```

{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

### logEvent(eventName, eventValues)

To Push Event

{% tabs %}
{% tab title="Plain JS" %}

```javascript
const { appsflyer: AppsFlyer } = window.WTN

AppsFlyer.logEvent("ADD_TO_CART", {
    name: "Cadburry",
    quantity: 1
})
```

{% endtab %}

{% tab title="ES 6+" %}

```javascript
import { logEvent } from "webtonative/AppsFlyer"

logEvent("ADD_TO_CART", {
    name: "Cadburry",
    quantity: 1
})
```

{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

### getAppsFlyerAppId()

To retrieve the AppsFlyer unique device identifier (AppsFlyer ID) for the current app installation.

{% hint style="success" %}
**Available on Android and iOS from 21st March, 2026.**
{% endhint %}

{% tabs %}
{% tab title="Plain JS" %}

```javascript
const { appsflyer: AppsFlyer } = window.WTN

AppsFlyer.getAppsFlyerAppId({
    callback: function (response) {
        console.log(response.appsFlyerId) // AppsFlyer unique device ID
    }
})
```

{% endtab %}

{% tab title="ES 6+" %}

```javascript
import { getAppsFlyerAppId } from "webtonative/AppsFlyer"

getAppsFlyerAppId({
    callback: (response) => {
        console.log(response.appsFlyerId) // AppsFlyer unique device ID
    }
})
```

{% endtab %}
{% endtabs %}

#### Callback Response

| Property      | Type   | Description                            |
| ------------- | ------ | -------------------------------------- |
| `type`        | string | Always `"getAppsFlyerAppId"`           |
| `appsFlyerId` | string | The AppsFlyer unique device identifier |

#### Example Response

```json
{
    "type": "getAppsFlyerAppId",
    "appsFlyerId": "1234567890123-1234567"
}
```

{% endstep %}
{% endstepper %}
