# Map mobile and web sessions

**URL:** <https://community.dynatrace.com/t/map-mobile-and-web-sessions/50522>\
**Category:** Real User Monitoring\
**Tags:** mobile-monitoring\
**Created:** [March 1, 2025, 10:42pm UTC](https://community.dynatrace.com/t/map-mobile-and-web-sessions/50522 "2025-03-01T22:42:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rdinis](https://avatars.discourse-cdn.com/v4/letter/r/e8c25b/32.png) [@rdinis](https://community.dynatrace.com/u/rdinis)\
**Post date:** [March 1, 2025, 10:42pm UTC](https://community.dynatrace.com/t/map-mobile-and-web-sessions/50522/1 "2025-03-01T22:42:52Z")

</div>

Hi all,

Im trying to learn the Dynatrace capacities with web and mobile app, so i build something to play 🙂

- Web application: easytravel on a vm in linux with oneagent
- Mobile application: Android with Kotlin with a webview

So, i have this code

```java
// Initializes and configures WebView
    private fun setupWebView() {
        val myWebView: WebView = findViewById(R.id.main_webview)
        Dynatrace.instrumentWebView(myWebView)
        myWebView.settings.javaScriptEnabled = true
        myWebView.loadUrl("http://192.168.0.102:8079") // ez travel on vm

        binding.mainWebview.webViewClient = object : WebViewClient() {
            override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
                return false // Ensures URLs open inside WebView, NOT Chrome
            }
        }
    }

```

I have mobile and web sessions, but they are splited, i want to map mobile to web sessions so i follow this [documentation](https://docs.dynatrace.com/docs/shortlink/oneagent-sdk-for-android#instrument-webview)

Can I have some lights why Im not able to map sessions?

Thanks,

RD

---

<div class="post-metadata">

**Author:** ![matthias\_hochri](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/matthias_hochri/32/15052_2.png) [@matthias\_hochri](https://community.dynatrace.com/u/matthias_hochri)\
**Post date:** [March 4, 2025, 8:26am UTC](https://community.dynatrace.com/t/map-mobile-and-web-sessions/50522/2 "2025-03-04T08:26:13Z")

</div>

Hey RD,

Usually auto instrumentation would take care for you so you don’t need to call instrumentWebView. This call also only adds the JavaScript interface. Still you need to use the Hybrid Monitoring configuration flag. Did you do that? Additionally one thing that you are probably missing is setting the configuration for domains. The Android agent doesn’t know that your VM is on 192.168.0.102, so you need to configure this domain in order for the cookies to be set there.

The cookies (dtAdk) will allow the session merge.

---

<div class="post-metadata">

**Author:** ![rdinis](https://avatars.discourse-cdn.com/v4/letter/r/e8c25b/32.png) [@rdinis](https://community.dynatrace.com/u/rdinis)\
**Post date:** [March 6, 2025, 6:10pm UTC](https://community.dynatrace.com/t/map-mobile-and-web-sessions/50522/3 "2025-03-06T18:10:44Z")

</div>

Thanks Matthias for the answer but i could not find the result that i wanted., yet&nbsp;:nerd\_face:

Let me explain better what i want to do.  
I have a web page that will be access by web view in mobile and browser.  
I would like to map the mobile session to the web session.  
But this not always happen.

Having this in consideration i still need to have the&nbsp;Hybrid Monitoring configuration flag?

This means that i have to add this to code

> DynatraceConfigurationBuilder(“\<YourApplicationID\>”, “\<ProvidedBeaconURL\>”)  
> .withHybridMonitoring(true)

> **[Instrumentation via OneAgent SDK for Android in RUM Classic](https://docs.dynatrace.com/docs/observe/digital-experience/rum-classic/mobile-applications/instrument-android-app/instrumentation-via-oneagent-sdk/oneagent-sdk-for-android)**
>
> Learn how to enrich mobile user experience monitoring in Android using OneAgent SDK.

---

<div class="post-metadata">

**Author:** ![matthias\_hochri](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/matthias_hochri/32/15052_2.png) [@matthias\_hochri](https://community.dynatrace.com/u/matthias_hochri)\
**Post date:** [March 7, 2025, 9:35am UTC](https://community.dynatrace.com/t/map-mobile-and-web-sessions/50522/4 "2025-03-07T09:35:30Z")

</div>

DynatraceConfigurationBuilder is something that you are using when doing a manual startup. So you are doing manual starting?

But in general your answer is correct. Additionally as said above you also need to call the builder API for adding domains.

---

<div class="post-metadata">

**Author:** ![rdinis](https://avatars.discourse-cdn.com/v4/letter/r/e8c25b/32.png) [@rdinis](https://community.dynatrace.com/u/rdinis)\
**Post date:** [March 8, 2025, 1:53am UTC](https://community.dynatrace.com/t/map-mobile-and-web-sessions/50522/5 "2025-03-08T01:53:35Z")

</div>

Ok, lets see the key points:

- Automatic instrumentation of webviews with oneagent (Web Aplication)
  - Domain equals&nbsp;192.168.0.102

- Mobile instrumentation with wizard Android - groovy

My build gradle of the project:

```java
dynatrace {
    configurations {
        sampleConfig {
            autoStart {
                applicationId 'applicationId'
                beaconUrl 'https://beaconUrl.bf.dynatrace.com/mbeacon'
            }
            userOptIn false
            agentBehavior.startupLoadBalancing true
            sessionReplay.enabled false
            exclude.classes "com.dynatrace.sample.android.app.MinimalActivity"
            hybridWebView {
                enabled true
                domains ["192.168.0.102"]
            }
        }
    }
}

```

Code

```java
// Initializes and configures WebView
    private fun setupWebView() {
        DynatraceConfigurationBuilder("appID", "https://bc.bf.dynatrace.com/mbeacon")
            .withHybridMonitoring(true)
            .withMonitoredDomains("192.168.0.102")
            .buildConfiguration()
        val myWebView: WebView = findViewById(R.id.main_webview)
        Dynatrace.instrumentWebView(myWebView)
        myWebView.settings.javaScriptEnabled = true
        myWebView.loadUrl("http://192.168.0.102:9200/")

        binding.mainWebview.webViewClient = object : WebViewClient() {
            override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
                return false // Ensures URLs open inside WebView, NOT Chrome
            }
        }
    }

```

I have tried every combination but it seems that the problem is between the keyboard and the pc&nbsp;:eyes:

---

<div class="post-metadata">

**Author:** ![matthias\_hochri](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/matthias_hochri/32/15052_2.png) [@matthias\_hochri](https://community.dynatrace.com/u/matthias_hochri)\
**Post date:** [March 10, 2025, 10:10am UTC](https://community.dynatrace.com/t/map-mobile-and-web-sessions/50522/6 "2025-03-10T10:10:51Z")

</div>

The DynatraceConfigurationBuilder is not needed as you are doing auto instrumentation through the build.gradle configuration anyways. Also the instrumentWebview is usually not needed, but not 100% sure because you are excluding the MinimalActivity.

Anyways, please adapt the configuration

```markup
hybridWebView {
   enabled true
   domains '192.168.0.102'
}

```

In general if you want to add more values it is something like this:

```markup
hybridWebView {
    enabled true
    domains '192.168.0.102', '...', '...'
}

```

Maybe also add ‘debug.agentLogging true’ to the configuration so you can see logs.

No worries. We are getting there. Thanks for your input.
