---
title: Track WebViews - Android
description: Track webviews with the Contentsquare Android SDK
lastUpdated: 05 March 2026
source_url:
  html: https://docs.contentsquare.com/en/csq-sdk-android/experience-analytics/track-webviews/
  md: https://docs.contentsquare.com/en/csq-sdk-android/experience-analytics/track-webviews/index.md
---

Android compatibility

Contentsquare **only** allows to track instances of `android.webkit.WebView`. `androidx.browser.customtabs` is **not** supported: The CSQ SDK **cannot** track what is happening within its context, and its content will **not** be visible in replays.

## Enable tracking in WebViews

### Where to inject your WebViews?

It is **essential** that the registration is done before a URL is loaded in your WebView. With that in mind, you should register your WebViews in `onCreate()` for Activities and `onCreateView()` for Fragments. Unregister them in the corresponding `onDestroy()` or `onDestroyView()` methods.

No matter where you decide to add the following injection code, keep in mind that it will not take effect until the next WebView content reload.

### WebView tracking lifecycle

Use the [`CSQ.registerWebView()`](../command-reference/#csqregisterwebview) API to start tracking a specific WebView and [`CSQ.unregisterWebView()`](../command-reference/#csqunregisterwebview) to stop tracking it.

### Tag setup

To complete the implementation, inject the **CS Tag in WebView mode** on your pages.

See 📚 [Mobile Apps WebView Tracking Documentation](https://docs.contentsquare.com/en/webview-tracking-tag/#manual-injection).

## Full example

Here is an Activity implementation. Register the WebView in `onCreate()` and unregister it in `onDestroy()`:

* Kotlin

  ```kotlin
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_web_view)


    val webView = findViewById<WebView>(R.id.webview)
    webView.settings.javaScriptEnabled = true
    webView.webViewClient = object : WebViewClient() {}


    // Inject the Bridge between the CS Tag in WebView mode and the SDK
    CSQ.registerWebView(webView)


    webView.loadUrl(DEFAULT_WEB_VIEW_CONTENT_URL)
    webView.reload()
  }


  override fun onDestroy() {
    super.onDestroy()


    val webView = findViewById<WebView>(R.id.webview)
    CSQ.unregisterWebView(webView)
  }
  ```

* Java

  ```java
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_web_view);


    WebView webView = findViewById(R.id.webview);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebViewClient(new WebViewClient() {});


    // Inject the Bridge between the CS Tag in WebView mode and the SDK
    CSQ.registerWebView(webView);


    webView.loadUrl(DEFAULT_WEB_VIEW_CONTENT_URL);
    webView.reload();
  }


  @Override
  protected void onDestroy() {
    super.onDestroy();


    WebView webView = findViewById(R.id.webview);
    CSQ.unregisterWebView(webView);
  }
  ```

If you are using Fragments, the approach is similar, but should be done in the `onCreateView()` method for registration and `onDestroyView()` method for unregistration.

## Validate your implementation of WebView tracking

*Currently, there is no way of validating the implementation on the native side only.*

### Validating the implementation on the web side

Once you arrive on the screen with the tracked WebView, you should see an initial confirmation log message:

```plaintext
WebView detected and WebView tracking enabled on native side
```

Specific logs are then emitted for:

* Page views fired by the WebView Tracking Tag in the same format as for screen views: `Screenview - Screen name: {{page name given}} - Screen number: 11`
* Taps and swipes detected by the WebView Tracking Tag in the same format as for defaults taps and swipe but with the target matching an HTML DOM element value: `Tap - Target: {Last view info: div:eq(0)} - Unresponsive: false`

***Going further:*** If you still have doubt, you can look for logs by filtering on `WebViewEventProcessor`. Their presence will confirm that it is well implemented on both web and native sides.
