To enable WebView tracking in your mobile app, you need to implement the Contentsquare Web Tracking Tag in every web page called in your mobile app for the WebView to communicate with our native SDK.
WebView tracking relies on:
The Contentsquare Web Tracking Tag in version
Contentsquare Mobile SDKs: Android SDK
4.22.0and later / iOS
Getting StartedSection titled Getting Started
The Web Tracking Tag is responsible for establishing communication with the SDK in the parent app. To set it up, you can follow the different implementation guidelines presented in The main Tracking Tag section.
Set the tag in WebView modeSection titled Set the tag in WebView mode
The web tracking tag needs to be set in WebView mode in order to collect data and pass them to the main SDK that will send them to the dedicated Apps project. To do so, the following command must to be added before loading the tracking tag (or it will be ignored):
Choosing a WebView Data Collection StrategySection titled Choosing a WebView Data Collection Strategy
There are different options for collecting data, and the strategy that is best for you will depend on various factors.
Some questions to consider include:
- Is the WebView page also visited by web browsers, or is it only used within a WebView context?
- Are the same teams responsible for these pages in both contexts (on the website and within a mobile app webview), or do different teams work closely together and share a lot of code?
- Does most of the tracking customization need to apply in both contexts (with little to no differences), such as session replay masking rules and event handling?
Depending on these questions, there are 2 main collection strategies that can be applied for WebViews:
- Use the same tracker (Tag ID) for both browser and WebView contexts
- Use a dedicated tracker (Tag ID) for pages created exclusively for WebViews (and/or pages used in both context but with different settings required).
Use the same tracker for Web & Webview contextsSection titled Use the same tracker for Web & Webview contexts
For pages visited both in the browser and in WebViews, the same tracker can be used for both the Web and WebView use cases. To do so:
- Load the Tag as when in the browser
- Activate the
isWebViewoption before the loading of the Web Tracking Tag
Here is a code snippet example:
Use a dedicated tracker for WebView contextSection titled Use a dedicated tracker for WebView context
For local pages, pages visited exclusively in WebView context and pages requiring different settings in WebView context, it is possible to use a dedicated tracker. Here is a code snippet example: