Track WebViews
Usage
Section titled UsageIn order to enable WebView tracking, two steps are required:
- Inject the Contentsquare Tracking Tag in WebView mode in the web pages loaded in your app’s WebViews. For more information on this step, refer to 📚 Mobile Apps WebView Tracking Documentation..
- Make sure JavaScript is enabled in your WebViews.
- Wrap your WebView widget with
ContentsquareWebViewWrapper
widget and implement it as explained below.
Implementation
Section titled ImplementationThe implementation can be done in two different ways depending on how your WebView allows the injection of scripts. These two different ways relies of two subtypes of WebViewWrapperDelegate
:
UserScriptWebViewWrapperDelegate
to inject the required Contentsquare script through User Scripts. Choose this if you use theflutter_inappwebview
package.JSChannelWebViewWrapperDelegate
to inject the required Contentsquare script through JavaScript channel. Choose this if you use packages likewebview_flutter
orflutter_webview_plugin
.
Examples
Section titled ExamplesThis example uses the flutter_inappwebview ↗ InAppWebView
widget.
This example uses the webview_flutter ↗ WebViewWidget
widget.
Validate WebView tracking
Section titled Validate WebView trackingTo validate the tracking of WebViews, refer to the platform-specific instructions.