Multi-Account Tracking: Change Track ID and Track Domain on Runtime
    • 2 Minutes to read
    • Dark
      Light

    Multi-Account Tracking: Change Track ID and Track Domain on Runtime

    • Dark
      Light

    Article summary

    Track ID and Track Domain are key components for tracking user behavior with the Mapp Intelligence SDK in mobile applications. These settings are typically added during the configuration phase. However, there may be scenarios where it’s necessary to change the configured settings at runtime, such as when offering a mobile app in multiple languages and tracking each language in a separate account.

    Changing accounts at runtime may affect the entry and exit pages in your analysis and could increase bounce rates. Please consult your customer success manager before using this feature.

    Methods / Classes

    Method

    Description

    abstract fun setIdsAndDomain(
     trackIds: List<String>, 
     trackDomain: String
    )

    Changes the globally configured track domain and track ID for the current session. To maintain these changes across sessions, save the configuration using the builder class.

    WebtrekkConfiguration.Builder(
     private val trackIds: List<String>, 
     private val trackDomain: String
    )

    This class is used to save the global configuration, including the track ID and domain for your account.

    Example: Change Track ID and Track Domain

    You can call the setIdsAndDomain function when opening a new screen. Here’s an example with multiple Track IDs:

    startNewScreen.setOnClickListener {
         val intent = Intent( this , NewScreen:: class .java)
         Webtrekk.getInstance().setIdsAndDomain(
             listOf( "111111111111111" , "222222222222222" ),
             "yourtrackdomain.mapp.com"
         )
         startActivity(intent)
    }
    public void newScreenOpen(View view) {
             Intent intent = new Intent( this , newScreen. class );
     
             Webtrekk.getInstance().setIdsAndDomain(
                 Arrays.asList(
                     "111111111111111" ,
                     "222222222222222"
                 ),
                 "yourtrackdomain.mapp.com"
             );
             startActivity(intent);
         }

    Known Limitations

    • The function only changes the Track ID and Domain for the current session. To persist this configuration across sessions, pass the same data to the main configuration function. More details are available in the Initialization documentation. An example can be found here.

    • There may be a short delay when changing settings.

    • Do not use this function with the same Track ID already in use (e.g., when using multiple Track IDs and only changing one).

    • Avoid calling this function more than once every 5 seconds, as frequent use may cause unwanted SDK behavior.


    Was this article helpful?