# Apps Flyer

{% hint style="info" %}
You'll need to import the javascript file in your website before starting from this [link](/javascript-apis/getting-started.md).
{% 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 %}


---

# 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.webtonative.com/javascript-apis/apps-flyer.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.
