Showing results for 
Show  only  | Search instead for 
Did you mean: 
Dynatrace Advisor
Dynatrace Advisor

How to tag a user in a session 

A session gets tagged when SDK API method is called.


for both Android and iOS.

Session is not being tagged?

Review the logs.

From the Application => Mobile app settings => Instrumentation settings.

If opt-in mode is enabled


Make sure that, for iOS, in the plist DTXUserOptIn is set to true or, for Android, in the configuration file that userOptIn  set to true

From Logs iOS: DTXUserOptIn , value: 1, Android : userOptIn=true

Confirm that the application code has the privacy notice added so users can set their preferences. Example here.


import Dynatrace

// Privacy settings configured below are only provided
// to allow a quick start with capturing monitoring data.
// This has to be requested from the user
// (e.g. in a privacy settings screen) and the user decision
// has to be applied similar to this example.
let privacyConfig = Dynatrace.userPrivacyOptions()
privacyConfig.dataCollectionLevel = .userBehavior
privacyConfig.crashReportingOptedIn = true
privacyConfig.crashReplayOptedIn = true
Dynatrace.applyUserPrivacyOptions(privacyConfig) { (Bool) in
// callback after privacy changed


// Privacy settings configured below are only provided
// to allow a quick start with capturing monitoring data.
// This has to be requested from the user
// (e.g. in a privacy settings screen) and the user decision
// has to be applied similar to this example.

These parts of code can be found in Application => Mobile app settings => Instrumentation wizard for each platform.

DataCollectionLevel meanings

  • OFF (the agent does not capture data.)
    from logs will be referenced to iOS:  dataCollectionLevel:0, Android: dataCollectionLevel=OFF
  • PERFORMANCE (the agent only captures anonymous performance data.)
    from logs will be referenced to iOS:  dataCollectionLevel:1, Android: dataCollectionLevel=PERFORMANCE
  • USER_BEHAVIOR (he agent captures performance and user data.)
    from logs will be referenced to iOS:  dataCollectionLevel:2, Android: dataCollectionLevel=USER_BEHAVIOR

In this situation, USER_BEHAVIOR is the only status in which the user will be tagged.


Search in the xcode console logs for the following, Here "Kazuya" name is tagged.

CREATED IDENTIFY_USER EVENT: <DTXMeasurement 0x7fcd89521410: visitorId=7868376413403 sessionId=12 sessionSequence=0 name=Kazuya startTimestamp=2021-08-19 14:13:56 +0000 customValue=0 duration=0.000000 sent=0 connectionType=w networkProtocol=802.11x batteryStrengthPercent=-2 freeMemoryPercent=0 activeMemoryPercent=42 inactiveMemoryPercent=42 wiredMemoryPercent=9 portraitOrientation=1 currentTag=-1 enclosingTag=0 customValueDouble=0.000000 eventType=60 self.eventTypeString=IdentifyUser lifecycleSequence0=18 lifecycleSequence1=0 lifecycleSequence2=0 lifecycleSequence3=0 threadId=1 bytesReceived=0 bytesSent=0 >



In this example, the application user is tagged with "Ace Ventura" and the corresponding log entry can be found in Logcat (either in Android Studio or with the adb logcat command-line tool)

2021-08-19 11:41:59.818 10455-10455/com.dynatrace.mobilelab D/dtxAgentCore

Changing the data collection level will generate a new user session. Meaning whenever the value changes the current session will end and a new one is created.


Some sessions are anonymous?

So if we are sure that the Dynatrace.identifyUser is being called and sometimes users are not tagged.

We have to confirm that this line of code "Dynatrace.identifyUser" is being called.

An easy way to do that is to print in the log a custom message


print("***WILL START TAGGING***")
print("***Tagged the user***")

If you don't see the printed parts in the logs, then identifyUser was never called.

Also, make sure that the passed variable to identify the user is not null or empty (simply by printing its value to the logs.)

If you pass a null or empty string to Dynatrace.identifyUser(""); the sessions won't be tagged.

Tracking a session from logs to Dynatrace?

From iOS logs:

Here the visitor ID is 14054083387977


From the logs search for visitorID: <visitorID>

2021-08-23 14:29:40.045093+0200 DynaPods[7304:249306] 🔼 FINE    📡 Communication  [DTXCommunicationsManager.m:1118-12803-2] sendMetrics for visitorId: 14054083387977 sessionId: 151, number of metrics to send: 12

From Android logs:

Here the visitor's session ID is 3672025434

From the logs at the beacon search for vi=<visitorID>

#12712.aPOST url[] data[vv=3&va=

or if there is a web request that is tagged by the android agent via MT_<visitorID>


Mobile Sessions are split:

  • On app termination.
  • On 30 minutes of inactivity.
  • After 6 hours of duration.
  • On more than 200 user actions.

    The inactivity timeout (10 min) is controlled by the Agent. When the app foregrounds it checks if the inactivity timeout was reached and creates a new session or continues the existing one (if the app was not purged from memory by the mobile OS when in the background). Session timeout is, also, enforced on the cluster if not done on a mobile device (~35 min by visit store).
Version history
Last update:
‎03 Jan 2023 09:57 AM
Updated by:
DynaMight Legend
DynaMight Legend

Great Write up @yngwie_lucero