Skip to main content
Skip table of contents

How to tag applications with WebViews ?

When tagging hybrid applications, first make sure you’re using the same site and collection domain on all screens—especially if the WebViews display pages from an already tagged site.

Why WebViews require specific handling

Piano Analytics identifies visitors differently on websites and in mobile applications:

  • Websites: visitor identification relies on cookies (with a specific cookie-based ID).

  • Applications: visitor identification relies on an ID generated by the mobile SDK.

In a hybrid app, if your native screens use the SDK ID while your WebView pages use the cookie-based ID, the same person can be counted as different visitors and their journey may split across multiple visits.

To avoid this, you must force the visitor ID generated on native screens to be used on WebView screens using the dedicated method provided by the Piano Analytics SDK for your platform.

Implementation overview

Use the appropriate SDK method to share/synchronize the native visitor ID with the WebView tagging so that WebView hits are associated with the same visitor as native hits.

Supported SDKs and libraries:

Differentiating WebView traffic from standard web traffic

Because WebView pages are typically tagged in JavaScript, it can be difficult to distinguish traffic coming from a WebView (inside your app) versus traffic from a standard mobile browser—especially if both send data to the same level 1 site.

  • Declare the context with a custom property
    If you must send both website and WebView traffic to the same site and you can’t reliably infer the origin, set a custom property in the WebView tagging to flag the context (e.g., app_webview=true, app_platform=ios, etc.). This allows you to segment WebView traffic in reporting.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.