# WebApp Integration

{% hint style="info" %}
This feature is supported in Android SDK 2.29.0 and above, and JavaScript SDK 11.24.1 and above.

For information about WebApp, see the [documentation](/en/development-guide/faq/web-app-intergration.md).
{% endhint %}

When rendering your own website via `WebView`, you can use the following configuration to use the Hackle JavaScript SDK included in your website with the same functionality as the Hackle Android SDK, without modifying the website code.

Once the bridge is configured, Hackle events generated in the WebView are collected through the Android SDK.

{% hint style="info" %}
The WebView bridge only processes data passed as a bridge from the Hackle JavaScript SDK via the Android SDK's JavascriptInterface.
{% endhint %}

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

```kotlin
...
Hackle.app.setWebViewBridge(webView)
...
```

{% endtab %}

{% tab title="Java" %}

```java
...
HackleApp.getInstance().setWebViewBridge(webView, HackleWebViewConfig.DEFAULT)
...
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
To use this feature, the **JavaScript web page must use the same App SDK Key**.

The Hackle Android WebView configuration interacts with the Hackle JavaScript SDK via Android's `Javascript Interface`. Make sure this configuration is completed before calling `WebView::loadUrl`.
{% endhint %}

### Integrating Auto-collected Events from WebView

{% hint style="info" %}
This feature is supported in Android SDK 2.62.0 and above, and JavaScript SDK 11.51.0 and above.
{% endhint %}

`$page_view` and `$engagement` generated on websites within the WebView are disabled by default. You can enable each auto-collected event by configuring `HackleWebViewConfig` when setting up the WebView bridge.

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

```kotlin
val webViewConfig = HackleWebViewConfig
	.builder()
	.automaticScreenTracking(true)
	.automaticEngagementTracking(true)
	.build()
Hackle.app.setWebViewBridge(webView, webViewConfig)
```

{% endtab %}

{% tab title="Java" %}

```java
HackleWebViewConfig webViewConfig = HackleWebViewConfig
	.builder()
	.automaticScreenTracking(true)
	.automaticEngagementTracking(true)
	.build();

HackleApp.getInstance().setWebViewBridge(webView, webViewConfig);
```

{% endtab %}
{% endtabs %}

#### Configuration Options

<table><thead><tr><th width="260.20703125">Option</th><th width="110">Default</th><th>Description</th></tr></thead><tbody><tr><td><code>automaticScreenTracking</code></td><td><code>false</code></td><td>Whether to collect <code>$page_view</code> generated on the website</td></tr><tr><td><code>automaticEngagementTracking</code></td><td><code>false</code></td><td>Whether to collect <code>$engagement</code> generated on the website</td></tr><tr><td><code>automaticRouteTracking</code></td><td><code>true</code></td><td>Whether to automatically collect page information generated on the website</td></tr></tbody></table>

{% hint style="info" %}
To automatically collect `$page_view` and `$engagement` on page navigation, set `automaticScreenTracking`, `automaticEngagementTracking`, and `automaticRouteTracking` all to `true`.

To [manually collect](/en/development-guide/javascript/event-tracking/js-track-page.md) `$page_view` and `$engagement` on page navigation, set `automaticScreenTracking` and `automaticEngagementTracking` to `true`, and set `automaticRouteTracking` to `false`.
{% endhint %}


---

# 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.hackle.io/en/development-guide/android/android-webapp-integration.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.
