Handle WebViews

Learn how to handle data collection with WebViews in a mobile app.


  • Successfully built and run app with SDKs installed and configured.

Learning objectives

In this lesson, you will:

  • Understand why you must take special considerations for WebViews.
  • Understand the code required to prevent tracking issues.

Potential tracking issues

If you send data from the native portion of the app and a WebView, each generates their own Experience Cloud ID (ECID). This results in disconnected hits and inflated visit/visitor data. More information about the ECID can be found in the ECID overview.

To solve for that undesirable situation, it’s important to pass the user’s ECID from the native portion to the WebView.

The Experience Cloud ID Service JavaScript extension in the WebView extracts the ECID from the URL instead of sending a request to Adobe for a new ID. The ID service uses this ECID to track the visitor.


In the Luma sample app, find the TermsOfService.swift file (in the Intro-Login_SignUp folder), and locate the following code:

// Show tou.html
let url = Bundle.main.url(forResource: "tou", withExtension: "html")
let myRequest = URLRequest(url: url!)

This is a simple way to load a WebView. In this case, it’s a local file but the same concepts apply to remote pages.

Refactor the webview code as shown below:

let url = Bundle.main.url(forResource: "tou", withExtension: "html")
if var urlString = url?.absoluteString {
    // Adobe Experience Platform - Handle Web View
    AEPEdgeIdentity.Identity.getUrlVariables {(urlVariables, error) in
        if let error = error {

        if let urlVariables: String = urlVariables {
            urlString.append("?" + urlVariables)

        DispatchQueue.main.async {
            self.webView.load(URLRequest(url: URL(string: urlString)!))
        print("Successfully retrieved urlVariables for WebView, final URL: \(urlString)")
} else {
    self.simpleAlert("Failed to create URL for webView")

You can learn more about the Identity.getUrlVariables API in the Identity for Edge Network extension API reference guide.


After reviewing the setup instructions section and connecting your simulator or device to Assurance, load the WebView and look for the Edge Identity Response URL Variables event from the com.adobe.griffon.mobile vendor.

To load the WebView, go to the home screen of the Luma app, select the “account” icon, followed by the “Terms of Use” in the footer.

After loading the WebView, select the event and review the urlvariables field in the ACPExtensionEventData object, confirming the following parameters are present in the URL: adobe_mc, mcmid, and mcorgid.

webview validation

A sample urvariables field can be seen below:

// Original (with escaped characters)

// Beautified

Visitor stitching via these URL parameters is currently supported in the Platform Web SDK (versions 2.11.0 or later) and VisitorAPI.js.

Next: Identity


Thank you for investing your time in learning about Adobe Experience Platform Mobile SDK. If you have questions, want to share general feedback, or have suggestions on future content, please share them on this Experience League Community discussion post

On this page