- 1 Minute to read
- Print
- DarkLight
WebView Tracking
- 1 Minute to read
- Print
- DarkLight
Tracking user activity within the web view of your app is crucial for a comprehensive analysis. To support WebView tracking in your app, the user ever ID must be sent to the Mapp Intelligence Pixel (e.g., Smart Tracking Pixel). This ensures that the user’s visit is properly tracked, using consistent user identification across web and app interactions.
Make sure that the corresponding functionality is enabled in the pixel:
SendViaSDK for Smart Pixel
Web to App Tracking for Tag Integration (Pixel V5)
Key Benefits
When using WebView tracking, the user remains within the app context throughout the session. The pixel sends tracked data back to the SDK, using the known user and system information. This approach ensures there are no session breaks or changes in path navigation between web and app activities.
Implementation
There are two methods to implement WebView tracking in your app. We recommend the first approach:
Using WebtrekkWebInterface (Recommended)
First, activate JavaScript in the
WebView
:webView.settings.javaScriptEnabled = true
Next, transfer the
WebtrekkWebInterface
object to the WebView JavaScript interface:webView.addJavascriptInterface(WebtrekkWebInterface(Webtrekk.getInstance()), WebtrekkWebInterface.TAG)
This method ensures seamless tracking by allowing the SDK to interact directly with the WebView.
Appending wt_eid to the URL
Alternatively, you can append the user Ever ID (
wt_eid
) to the URL when loading the web page in the WebView:webView.loadUrl("https://your_website_url.com/?wt_eid=the ever id"
This method also enables user tracking, though it’s less flexible compared to the first approach.
Additional Resources
For more detailed information on building web apps in WebView, refer to the official Android documentation: Building web apps in WebView.