---
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: 06 February 2026
source_url:
  html: https://docs.contentsquare.com/en/webview-tracking-tag/
  md: https://docs.contentsquare.com/en/webview-tracking-tag/index.md
---

## Introduction

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

## Platform implementation

See specific guide for each platform:

* 📚 [iOS](https://docs.contentsquare.com/en/ios/track-webviews/)
* 📚 [Android](https://docs.contentsquare.com/en/android/track-webviews/)
* 📚 [Flutter](https://docs.contentsquare.com/en/flutter/track-webviews/)
* 📚 [React Native](https://docs.contentsquare.com/en/react-native/track-webviews/)

## Tracking tag configuration

We support implementing the **tracking tag** via [Google Tag Manager](#google-tag-manager-template) or [manually](#manual-injection). Note that GTM is the preferred method of injection of the Contentsquare Tag.

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 execute 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 (Template)

You may already have implemented our GTM Tag (`Contentsquare - Main Tag`) for your website. Follow these steps to implement or verify the WebView setup.

1. Open your container and go to the **templates** section. ![](https://docs.contentsquare.com/_astro/main-1.BR8xO2Cv_Z1Rabw1.webp)

2. Select **Search gallery**. ![](https://docs.contentsquare.com/_astro/main-2.CDPvDirB_Z1usb2F.webp)

3. Type in **`contentsquare`** and select the **Contentsquare - Main tag** option. ![](https://docs.contentsquare.com/_astro/main-3.Bc6oAB7U_ZQKWY9.webp)

4. Click **Add to workspace**. ![](https://docs.contentsquare.com/_astro/main-4.B_pYlUCm_ZF3cFv.webp)

5. Confirm your choice by selecting **Add** ![](https://docs.contentsquare.com/_astro/main-5.SPp88Wgv_tc1tk.webp)

6. Go to the Tags section and click the **New** button to create a new tag. ![](https://docs.contentsquare.com/_astro/add-tag.DuGAskV4_1e0yKr.webp)

7. Configure it by selecting the top-right button. ![](https://docs.contentsquare.com/_astro/tag-config.krkkPQIC_19Jyy1.webp)

8. Search for **`contentsquare`** and select the **Contentsquare - Main tag** template that you've previously added to your container. ![](https://docs.contentsquare.com/_astro/new-main.BLrxNtUo_ZBCPQD.webp)

9. Confirm that your `my_web_tag_id` is correctly added. This should have been provided by your Contentsquare contact during your web implementation.

10. Similarly, confirm that your **my\_webview\_tag\_id** is properly configured. This is also provided by your Contentsquare contact. ![](https://docs.contentsquare.com/_astro/gtm_cs-contentsquare-tag_9_steps.DkNwrSAY_Z2k1YT1.webp)

11. Select the **DOM Ready** as trigger. ![](https://docs.contentsquare.com/_astro/gtm_cs-contentsquare-tag_11_steps.BhwqePvU_1oApNs.webp)

### 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).
