# Facebook App Events

{% hint style="info" %}

<pre data-overflow="wrap"><code>You'll need to import the javascript file in your website before starting from this <a data-footnote-ref href="#user-content-fn-1">link</a>.
</code></pre>

{% endhint %}

## Automatically Logged Events

When using the Facebook SDK, certain events in your app are automatically logged and collected for Facebook Events Manager unless you disable automatic event logging. These events are relevant for all use cases - targeting, measurement and optimisation.\
Learn more about Automatically Logged Events : \
**Android:** <https://developers.facebook.com/docs/app-events/getting-started-app-events-android#auto-events>\
**iOS:** <https://developers.facebook.com/docs/app-events/getting-started-app-events-ios#auto-events>

## Manually Log Events(Custom Events) <a href="#log-manually" id="log-manually"></a>

1\) Regular Events\
To send a custom event to Facebook, create a javascript object with the fields:

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

```markup
const { events: FacebookEvents} = window.WTN.facebook

FacebookEvents.send({
    event: "MY_EVENT", 
    valueToSum: 10, //optional
    parameters: { // optional
        name: "webtonative"
    }
})

```

{% endtab %}

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

```
import { send } from "webtonative/Facebook/events"

send({
    event: "MY_EVENT", 
    valueToSum: 10, //optional
    parameters: { // optional
        name: "webtonative"
    }
})

```

{% endtab %}
{% endtabs %}

2\) Purchase Events\
There is a special case for purchases and Facebook's SDK will send the event more immediately:

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

```markup
const { events: FacebookEvents} = window.WTN.facebook

FacebookEvents.sendPurchase({
    amount: 3.14, 
    currency: "INR",
    parameters: { // optional
        name: "webtonative"
    }
})

```

{% endtab %}

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

```
import { sendPurchase } from "webtonative/Facebook/events"

sendPurchase({
    amount: 3.14, 
    currency: "INR",
    parameters: { // optional
        name: "webtonative"
    }
})

```

{% endtab %}
{% endtabs %}

The list of string constants for event names and parameter keys can be found here:

* **Android**: <https://developers.facebook.com/docs/app-events/reference#standard-events>
* **iOS**: <https://developers.facebook.com/docs/app-events/reference#standard-events-2>

[^1]: <https://docs.webtonative.com/javascript-apis/getting-started>


---

# 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/facebook-app-events.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.
