Skip to main content

Setting User ID

Setting User ID via localStorage Interface

Before the agent code executes, set the key TY_USER_ID in localStorage. The agent will use the set ID as the user ID for upload.

localStorage.setItem('TY_USER_ID', 'user1');

Example code:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script>
// Set user ID
localStorage.setItem('TY_USER_ID', 'user1');
</script>
<!-- Import agent -->
<script src="./tingyun_rum.js"></script>
</head>
<body>
</body>
</html>

Setting User ID via Agent Interface

Example:

window.TINGYUN && window.TINGYUN.setUid('username1');

This method requires the agent to be loaded.

Customizing Device ID

Setting Device ID via localStorage Interface

Before the agent code executes, set the key TY_DEVICE_N_ID in localStorage. The agent will use the set ID as the device ID for upload.

localStorage.setItem('TY_DEVICE_N_ID', 'device1');

Example code:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script>
// Set device ID
localStorage.setItem('TY_DEVICE_N_ID', 'device1');
</script>
<!-- Import agent -->
<script src="./tingyun_rum.js"></script>
</head>
<body>
</body>
</html>

Setting Device ID via Agent Interface

Example:

window.TINGYUN && window.TINGYUN.setDid('device1');

This method requires the agent to be loaded.