# Event dispatchers

*Available in Batch 1.15.0 and higher*

In this article, we'll go through the process of improving your external analytics by either installing a premade event dispatcher or making your own one.

## What is an event dispatcher?

Batch can trigger with a number of analytics-oriented events that might be of interest in external analytic tools. An event dispatcher is the code that listens to those events, and *dispatches* them to the solution of your choice.

## Add a "ready-to-go" dispatcher

Batch provide you with premade dispatchers for specific use cases (aka ready-to-go dispatcher). They are enabled by simply adding them in your dependency, and will automatically track events into your analytics solution with a predetermined structure

<table data-view="cards" data-full-width="false"><thead><tr><th></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>Firebase</td><td><a href="https://38998153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCL8wF0y1T2vLnm3yR2MW%2Fuploads%2FPZmkSmtlDqEbSbRy56MA%2Flogo_firebase.png?alt=media&#x26;token=c4ae3fd3-faba-45f2-8788-31ae3e7bb0f7">logo_firebase.png</a></td><td><a href="event-dispatchers/firebase">firebase</a></td></tr><tr><td>Piano Analytics</td><td><a href="https://38998153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCL8wF0y1T2vLnm3yR2MW%2Fuploads%2FvOCjYN4KkjNvVQPpm91R%2Flogo_piano_analytics.jpg?alt=media&#x26;token=43681fa8-68b8-4b46-84fd-979d2af99bce">logo_piano_analytics.jpg</a></td><td><a href="event-dispatchers/piano-analytics">piano-analytics</a></td></tr><tr><td>AT Internet</td><td><a href="https://38998153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCL8wF0y1T2vLnm3yR2MW%2Fuploads%2FIrPkYXPCdRubPSOt401b%2Fat_internet_logo.jpeg?alt=media&#x26;token=99f49529-eed0-4ab1-8826-cb81a4bbc5cf">at_internet_logo.jpeg</a></td><td><a href="event-dispatchers/at-internet">at-internet</a></td></tr><tr><td>Mixpanel</td><td><a href="https://38998153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCL8wF0y1T2vLnm3yR2MW%2Fuploads%2F486B1C4wzI8so5UoeBqU%2Fmixpanel_logo.jpg?alt=media&#x26;token=2778674c-cba9-4b61-90ff-a518d8fb34ac">mixpanel_logo.jpg</a></td><td><a href="event-dispatchers/mixpanel">mixpanel</a></td></tr></tbody></table>

## Create a custom dispatcher

Or, if you need, you can implement your own dispatcher.

{% content-ref url="event-dispatchers/custom" %}
[custom](https://doc.batch.com/developer/sdk/android/event-dispatchers/custom)
{% endcontent-ref %}

## Access data from the event

The Batch SDK will inform you when one of the following event happen:

* Push notification displayed : Triggered when a push notification is displayed (only available on Android).
* Push notification clicked : Triggered when a push notification is clicked.
* Push notification dismissed : Triggered when a push notification is dismissed (only available on Android).
* Message showed : Triggered when an in-app or landing message appear on the screen.
* Message closed : Triggered when an in-app or landing message is explicitly closed by the user (using the close button or a dismiss CTA/Global tap).
* Message auto-closed : Triggered when an in-app message or landing is closed by the auto-close timer.
* Message clicked : Triggered when an in-app or landing Click-To-Action is clicked or when the in-app/landing is global tapped (except if the CTA/Global Tap is a dismiss, then a closed event is triggered).

With every events come a `Payload` object, allowing you to access data associated with the event, such as a push notification custom payload value, or the tracking ID of an in-app or landing campaign.

{% tabs %}
{% tab title="Kotlin" %}

```kotlin
override fun dispatchEvent(type: Batch.EventDispatcher.Type, payload: Batch.EventDispatcher.Payload) {
    Log.d("Dispatcher", "I'm dispatching : " + type.name + ", " + payload.trackingId)
}
```

{% endtab %}

{% tab title="Java" %}

```java
public void dispatchEvent(@NonNull Batch.EventDispatcher.Type type, @NonNull Batch.EventDispatcher.Payload payload){
    Log.d("Dispatcher", "I'm dispatching : " + type.name() + ", " + payload.getTrackingId());
}
```

{% endtab %}
{% endtabs %}
