# Hybrid Mobile User Sessions and Web Requests/User Actions

**URL:** <https://community.dynatrace.com/t/hybrid-mobile-user-sessions-and-web-requests-user-actions/19721>\
**Category:** Real User Monitoring\
**Tags:** real-user-monitoring-classic, mobile-monitoring, extensions, user-sessions\
**Created:** [July 2, 2020, 11:15am UTC](https://community.dynatrace.com/t/hybrid-mobile-user-sessions-and-web-requests-user-actions/19721 "2020-07-02T11:15:11Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Babar\_Qayyum](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/babar_qayyum/32/13620_2.png) [@Babar\_Qayyum](https://community.dynatrace.com/u/Babar_Qayyum)\
**Post date:** [July 2, 2020, 11:15am UTC](https://community.dynatrace.com/t/hybrid-mobile-user-sessions-and-web-requests-user-actions/19721/1 "2020-07-02T11:15:11Z")

</div>

Dear All,

We recently instrumented a hybrid mobile application using the Cordova plugin to have the Mobile RUM (external) performance data.

Now the following things bothering me:

- Top web requests appearing under **the network performance \> top providers \>**  **our publically available external** , which cannot correlate to any user session.
- Secondly, the user session details are showing only the below events and actions.  
 ![1593688291947.png](https://global.discourse-cdn.com/dynatrace/original/3X/4/3/4311528243b8262611b1d44a5a437f8553a2c63c.png)

Regards,

Babar

---

<div class="post-metadata">

**Author:** ![thomas\_billi](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/thomas_billi/32/25487_2.png) [@thomas\_billi](https://community.dynatrace.com/u/thomas_billi)\
**Post date:** [July 6, 2020, 3:47pm UTC](https://community.dynatrace.com/t/hybrid-mobile-user-sessions-and-web-requests-user-actions/19721/2 "2020-07-06T15:47:05Z")

</div>

Hi Babar!

for 1:

What kind of library are you using for the web requests? If they originate from a User Action in the web part and go through a library (or your own implementation) to the native part of the app, then they can not be correlated. Which libraries are you using?

for 2:

When setting up the Cordova mobile app through the Dynatrace instrumentation wizard, a web application is created. If the UI of your app is mainly written in web technologies, then all the User Actions will be sent to this web application. Please note that User Actions in the web application will only be created if they can be correlated with a web request.

–Thomas

---

<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:** [July 7, 2020, 6:12am UTC](https://community.dynatrace.com/t/hybrid-mobile-user-sessions-and-web-requests-user-actions/19721/3 "2020-07-07T06:12:07Z")

</div>

If you want to have more visibility there is currently a workaround possible:

```auto
async makeRequest() {
	// Set Mobile dtAdk cookie because native web request don't add cookies
	this.http.setCookie("YOUR_URL", "dtAdk=" + this.getCookieValue("dtAdk"));
	// Create XHR Action via JavaScript OneAgent
	let actionId = dtrum.enterXhrAction("Mobile First HTTP", XhrActionMode.CREATE_ACTION_WITH_USER_INPUT, 'YOUR_URL');
	// Make HTTP Request with x-dtpc, x-dtreferer and x-dynatrace header
	await this.http.get('YOUR_URL', {}, { "x-dtpc": this.getCookieValue("dtPC"), "x-dtreferer": dT_.gAR(actionId), "x-dynatrace": "" });
	// Leave XHR After request is done
	dtrum.leaveXhrAction(actionId);
}

getCookieValue(a) {
	var b = document.cookie.match('(^|[^;]+)\\s*' + a + '\\s*=\\s*([^;]+)');
	return b ? b.pop() : '';
}

```

this.http is the http library where you are firing the web requests. Basically this snippet does the following:

1. Set the current dtAdk Cookie onto the URL where the request happens (This can be changed to the domain and not the URL directly)
2. JS Agent is creating an XHR Action
3. Web Request will be tagged with 3 dynatrace related headers (x-dtpc, x-dtreferer, x-dynatrace)
4. Leave the XHR Action

Result: You have an XHR Action in the User session with a web request which is linked to the server side.

---

<div class="post-metadata">

**Author:** ![Babar\_Qayyum](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/babar_qayyum/32/13620_2.png) [@Babar\_Qayyum](https://community.dynatrace.com/u/Babar_Qayyum)\
**Post date:** [July 7, 2020, 2:22pm UTC](https://community.dynatrace.com/t/hybrid-mobile-user-sessions-and-web-requests-user-actions/19721/4 "2020-07-07T14:22:13Z")

</div>

Hello [@Matthias H.](https://answers.dynatrace.com/users/16273/view.html)

Thank you for your kind reply with a workaround solution. Let me go back to the developers especially those who instrumented the mobile application and then I will come back to you for further assistance.

Regards,

Babar

---

<div class="post-metadata">

**Author:** ![Babar\_Qayyum](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/babar_qayyum/32/13620_2.png) [@Babar\_Qayyum](https://community.dynatrace.com/u/Babar_Qayyum)\
**Post date:** [July 7, 2020, 2:23pm UTC](https://community.dynatrace.com/t/hybrid-mobile-user-sessions-and-web-requests-user-actions/19721/5 "2020-07-07T14:23:39Z")

</div>

Hello [@Thomas B.](https://answers.dynatrace.com/users/37349/view.html)

Thank you for your kind reply. Let me go back to the developers to grab this information and then I will come back to you for further assistance.

Regards,

Babar

---

<div class="post-metadata">

**Author:** ![Babar\_Qayyum](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/babar_qayyum/32/13620_2.png) [@Babar\_Qayyum](https://community.dynatrace.com/u/Babar_Qayyum)\
**Post date:** [July 8, 2020, 10:16am UTC](https://community.dynatrace.com/t/hybrid-mobile-user-sessions-and-web-requests-user-actions/19721/6 "2020-07-08T10:16:55Z")

</div>

Hello [@Thomas B.](https://answers.dynatrace.com/users/37349/view.html)

I got the below answer.

The HTTP requests are managed by the IBM Mobile First Plugin:

Regards,

Babar

---

<div class="post-metadata">

**Author:** ![thomas\_billi](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/thomas_billi/32/25487_2.png) [@thomas\_billi](https://community.dynatrace.com/u/thomas_billi)\
**Post date:** [July 14, 2020, 5:37am UTC](https://community.dynatrace.com/t/hybrid-mobile-user-sessions-and-web-requests-user-actions/19721/7 "2020-07-14T05:37:57Z")

</div>

Hey Babar! Thanks for the info. Does the snippet, that Matthias provided, solve the problem? If not, could you then please open a support request so this can be handled properly?

---

<div class="post-metadata">

**Author:** ![zero\_ho](https://avatars.discourse-cdn.com/v4/letter/z/9de053/32.png) [@zero\_ho](https://community.dynatrace.com/u/zero_ho)\
**Post date:** [November 23, 2020, 2:49am UTC](https://community.dynatrace.com/t/hybrid-mobile-user-sessions-and-web-requests-user-actions/19721/8 "2020-11-23T02:49:05Z")

</div>

[@Matthias H.](https://answers.dynatrace.com/users/16273/view.html)

I have a similar scenario where visibility is broken with the Cordova Hybrid Web view deployment. We can see mobile actions entering Dynatrace but we cannot track the underlying mapping to server side requests.

May I ask if your shared script can be applied once (i.e. on a commonly accessed web view page) on a primary web view page? Or it needs to be applied everywhere?

Thank you.

---

<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:** [November 23, 2020, 9:03am UTC](https://community.dynatrace.com/t/hybrid-mobile-user-sessions-and-web-requests-user-actions/19721/9 "2020-11-23T09:03:15Z")

</div>

It basically needs to be applied where you execute your network call. If you have not a single point which is executing the call, you need to apply it for every call. If you need more help open a support case so we can analyze the situation.
