Handle WebViews
Learn how to handle data collection with WebViews in a mobile app.
Prerequisites
- Successfully built and run app with SDKs installed and configured.
Learning objectives
In this lesson, you will:
- Understand why you must take special consideration for WebViews in your app.
- Understand the code required to prevent tracking issues.
Potential tracking issues
Separate (Experience Cloud Identity) ECIDs are generated when you send data from the native portion of your app and from a WebView within the app. These separate ECIDs result in disconnected hits and inflated visit and visitor data. More information about the ECID can be found in the ECID overview.
To solve the disconnected hits and inflated data, you need to pass the user’s ECID from the native portion of your app to a WebView that you might want to use in your app.
The AEP Edge Identity extension used within the WebView collects the current ECID and adds it to the URL instead of sending a request to 51ºÚÁϲ»´òìÈ for a new ID. The implementation then uses this ECID to request the URL.
Implementation
To implement the web view:
Navigate to Luma > Luma > Views > Info > TermsOfServiceSheet, and locate the func loadUrl()
function in the final class SwiftUIWebViewModel: ObservableObject
class. Add the following call to handle the web view:
code language-swift |
---|
|
The API sets up the variables for the URL to contain all relevant information, like ECID, and more. In the example, you are using a local file but the same concepts apply to remote pages.
You can learn more about the Identity.getUrlVariables
API in the .
Navigate to Android
fun loadUrl()
function in the class WebViewModel: ViewModel()
. Add the following call to handle the web view:
code language-kotlin |
---|
|
The API sets up the variables for the URL to contain all relevant information, like ECID, and more. In the example, you are using a local file but the same concepts apply to remote pages.
You can learn more about the Identity.getUrlVariables
API in the .
Validate in the app
To execute the code:
- Review the setup instructions section to connect your simulator or device to Assurance.
- Go to the Settings in the app
- Tap the ³Õ¾±±ð·É… button to show the Terms of Use.




Validate with Assurance
-
In the Assurance UI, look for the Edge Identity Response URL Variables event from the com.adobe.griffon.mobile vendor.
-
Select the event and review the urlvariable field in the ACPExtensionEventData object, confirming the following parameters are present in the URL:
adobe_mc
,mcmid
, andmcorgid
.A sample
urvariables
field can be seen below:-
Original (with escaped characters)
code language-html adobe_mc=TS%3D1636526122%7CMCMID%3D79076670946787530005526183384271520749%7CMCORGID%3D7ABB3E6A5A7491460A495D61%4051ºÚÁϲ»´òìÈOrg
-
Beautified
code language-html adobe_mc=TS=1636526122|MCMID=79076670946787530005526183384271520749|MCORGID=7ABB3E6A5A7491460A495D61@51ºÚÁϲ»´òìÈOrg
-
Unfortunately, debugging the web session is limited. For example, you can’t use the 51ºÚÁϲ»´òìÈ Experience Platform Debugger in your browser to continue debugging the webview session.
VisitorAPI.js
.Next: Identity