> For the complete documentation index, see [llms.txt](https://doc.batch.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.batch.com/developer/sdk/ios/event-dispatchers/piano-analytics.md).

# Piano Analytics

The Piano Analytics dispatcher automatically dispatches events to the [Piano SDK](https://developers.atinternet-solutions.com/piano-analytics/data-collection/sdks/ios-swift), including AT tags when they are available.

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

```
https://github.com/BatchLabs/Batch-iOS-piano-dispatcher.git
```

{% endtab %}

{% tab title="CocoaPods" %}
{% code title="Podfile" %}

```
pod 'BatchPianoDispatcher'
```

{% endcode %}
{% endtab %}

{% tab title="Carthage" %}
{% code title="Cartfile" %}

```
github "BatchLabs/Batch-iOS-piano-dispatcher"
```

{% endcode %}
{% endtab %}
{% endtabs %}

By default the dispatcher will handle UTM tracking and will send events only as Piano [On-site Ads events](https://developers.atinternet-solutions.com/piano-analytics/data-collection/how-to-send-events/standard-events#onsite-ads).

Register the dispatcher and update the configuration as following:

```swift
@import BatchPianoDispatcher

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    let pianoDispatcher = BatchPianoDispatcher.instance
    
    func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
        // PA Configuration
        pa.setConfiguration(ConfigurationBuilder()
            .withCollectDomain("logsx.xiti.com")
            .withSite(123456789)
            .build()
        )
        // Uncomment if you want to enable custom event sending (default: false)
        //pianoDispatcher.enableCustomEvents = true

        // Uncomment if you want to disable On-Site Ads event sending (default: true)
        //pianoDispatcher.enableOnSiteAdsEvents = false

        // Uncomment if you want to disable UTM tracking (default: true)
        //pianoDispatcher.enableUTMTracking = false
        
        BatchEventDispatcher.add(pianoDispatcher)
        
        [...]

        BatchSDK.start(withAPIKey: "YOUR_API_KEY")
        return true
    }
}
```

{% hint style="info" %}
If you enable custom events, you also need to define them in your Piano Data Model. If so, please refer to the [custom event/property list](https://github.com/BatchLabs/Batch-iOS-piano-dispatcher/blob/master/Sources/BatchPianoDispatcher/BatchPianoDispatcher.swift#L27).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://doc.batch.com/developer/sdk/ios/event-dispatchers/piano-analytics.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
