---
title: WebView Tracking - WebView
description: Enable WebView tracking in your mobile app by adding the Contentsquare Web Tracking Tag on web pages called by your mobile app
lastUpdated: 12 June 2026
source_url:
  html: https://docs.contentsquare.com/en/webview-tracking-tag/
  md: https://docs.contentsquare.com/en/webview-tracking-tag/index.md
---

> Documentation index: https://docs.contentsquare.com/llms.txt
> Use this file to discover all available pages before exploring further.

To track WebViews in your app using Contentsquare, you'll need to configure the tracking tag and the mobile SDK to work together.

Refer to the specific guide for each mobile platform:

* ![](https://docs.contentsquare.com/logos/ios.svg)

  ### [iOS](https://docs.contentsquare.com/en/csq-sdk-ios/experience-analytics/track-webviews/)

* ![](https://docs.contentsquare.com/logos/android.svg)

  ### [Android](https://docs.contentsquare.com/en/csq-sdk-android/experience-analytics/track-webviews/)

* ![](https://docs.contentsquare.com/logos/flutter.svg)

  ### [Flutter](https://docs.contentsquare.com/en/csq-sdk-flutter/experience-analytics/track-webviews/)

* ![](https://docs.contentsquare.com/logos/react-native.svg)

  ### [React Native](https://docs.contentsquare.com/en/csq-sdk-react-native/experience-analytics/track-webviews/)

## Tracking tag configuration

We support implementing the **tracking tag** via [Google Tag Manager (Custom HTML)](#google-tag-manager-custom-html) or [manually](#manual-injection).

Required trackpageview call

You **must** include a `trackPageview` command in your tag code. This call is essential to initialize and start the tracking process in WebView environments. Without this command, tracking will not function properly.

## The trackPageview command

The `trackPageview` command is a mandatory component of your WebView tracking implementation. This command:

* **Initializes the tracking session** when the page loads in the WebView
* **Enables data collection** by signaling to Contentsquare that tracking should begin
* **Must be called from the tag code** regardless of whether you use GTM or manual injection
* **Works in conjunction with the mobile SDK** to ensure proper data synchronization

The command typically follows this format:

```javascript
window._uxa.push([
  "trackPageview",
  window.location.pathname + window.location.hash.replace("#", "?__")
]);
```

This call should be included in every implementation method described below. (see [Track Pageviews](https://docs.contentsquare.com/en/webview-tracking-tag/track-pageviews/#trackpageview-command-differences))

### Manual injection

To set up the tracking tag on your website, add the following lines of code on every page you want to analyze, either at the end of the `<body>` tag.

```html
<script type="text/javascript">
  (function () {
    window._uxa = window._uxa || [];


    var tag_id = MY_WEB_TAG_ID;


   function isWebView() {
      return navigator.userAgent.indexOf('CS_WebView') !== -1 ||
      typeof CSJavascriptBridge != 'undefined' ||
      window.CS_isWebView;
   }


    if (isWebView()) {
      window._uxa.push(["setOption", "isWebView", true]);
      tag_id = MY_WEBVIEW_TAG_ID;
    }


    // This trackPageview call is mandatory to start tracking
    window._uxa.push([
      "trackPageview",
      window.location.pathname + window.location.hash.replace("#", "?__")
    ]);


    var mt = document.createElement("script");
    mt.type = "text/javascript";
    mt.async = true;
    mt.src = `https://t.contentsquare.net/uxa/${tag_id}.js`;
    document.getElementsByTagName("head")[0].appendChild(mt);
  })();
</script>
```

This code creates a function which will add an asynchronous call to a script and then run the function. This is a way to avoid other elements loading being blocked on the page. This reduces the impact of the tag on your website's performance.

### Google Tag Manager (Custom HTML)

If your page loads in both a web and WebView environment, you should use a variable to determine whether the page is running in a WebView context before integrating the tracking tag. The Contentsquare Android and iOS SDK injects a `window.CS_isWebView` variable into the WebView to simplify the integration.

1. Add a new tag on your workspace. ![](https://docs.contentsquare.com/_astro/gtm_cs-contentsquare-custom_tag_1_steps.BENbpEK3_Z2aHmtu.webp)

2. Select "Choose a tag type to begin setup…". ![](https://docs.contentsquare.com/_astro/gtm_cs-contentsquare-custom_tag_2_steps.BysaN0E9_Z2ekpT6.webp)

3. In the list, pick the "Custom HTML" tag. ![](https://docs.contentsquare.com/_astro/gtm_cs-contentsquare-custom_tag_3_steps._SSKffpK_1zgPme.webp)

4. Copy and paste the following code in the Tag Configuration HTML section:

   ```html
   <script type="text/javascript">
     (function () {
       window._uxa = window._uxa || [];


       var tag_id = MY_WEB_TAG_ID;


       function isWebView() {
         return navigator.userAgent.indexOf('CS_WebView') !== -1 ||
         typeof CSJavascriptBridge != 'undefined' ||
         window.CS_isWebView;
       }


       if (isWebView())) {
         window._uxa.push(["setOption", "isWebView", true]);
         tag_id = MY_WEBVIEW_TAG_ID;
       }


       // This trackPageview call is mandatory to start tracking
       window._uxa.push([
         "trackPageview",
         window.location.pathname + window.location.hash.replace("#", "?__")
       ]);


       var mt = document.createElement("script");
       mt.type = "text/javascript";
       mt.async = true;
       mt.src = `https://t.contentsquare.net/uxa/${tag_id}.js`;
       document.getElementsByTagName("head")[0].appendChild(mt);
     })();
   </script>
   ```

   ![](https://docs.contentsquare.com/_astro/gtm_cs-contentsquare-custom_tag_4_steps.uLvjbGsV_1l7N2k.webp)

5. Select "Choose a trigger to make this tag fire…" and pick "All Pages" from the list. ![](https://docs.contentsquare.com/_astro/gtm_cs-contentsquare-custom_tag_trigger_steps.ztBM7n81_lzHG5.webp)

Warning

`window.CS_isWebView` is available since Contentsquare's iOS SDK 4.36.0, Android SDK 4.32.0, React Native Bridge 3.9.0 or Flutter Plugin 4.13.0. If you have a custom way of checking if the page is loaded in a WebView, replace `window.CS_isWebView` with your solution.

## Validate WebView tracking

To verify WebView tracking, refer to the documentation available for [iOS](https://docs.contentsquare.com/en/ios/track-webviews/#validate-webview-tracking) and [Android](https://docs.contentsquare.com/en/android/track-webviews/#validating-the-implementation-on-the-web-side).
