WebView Tracking

Prev Next

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:

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:

  1. 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.

  2. 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. You should also add wt_t, which includes a timestamp (valid for up to 15 minutes to prevent ID misuse):

    webView.loadUrl("https://your_website_url.com/?wt_eid=the ever id&wt_t=time stamp"

    This method also enables user tracking, though it’s less flexible than 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.