The Amp Devcenter Test Developer Hub

Welcome to the Amp Devcenter Test developer hub. You'll find comprehensive guides and documentation to help you start working with Amp Devcenter Test as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Setting Custom User IDs

Setting Custom User IDs

If your app has its own login system that you want to track users with, you can call setUserId at any time:

amplitude.getInstance().setUserId('USER_ID');
[[Amplitude] instance] setUserId:@"USER_ID"];
Amplitude.getInstance().setUserId("USER_ID");
Amplitude.Instance.setUserId("USER_ID");

You can also add the User ID as an argument to the init call:

amplitude.getInstance().init('API_KEY', 'USER_ID');
[[Amplitude] instance] initializeApiKey:@"API_KEY" userId:@"USER_ID"];
Amplitude.getInstance().initialize(this, "API_KEY", "USER_ID");
Amplitude.Instance.init("API_KEY", "USER_ID");

You should not assign users a User ID that could change as each unique User ID is interpreted as a unique user in Amplitude. Please see our article on how we identify and count unique users for further information.

Logging Out and Anonymous Users

A user's data will be merged on the backend so that any events up to that point from the same browser will be tracked under the same user. If a user logs out or you want to log the events under an anonymous user, you will need to:

  1. Set the userId to null.
  2. Regenerate a new deviceId.

After doing that, events coming from the current user/device will appear as a brand new user in Amplitude. Note: If you choose to do this, you will not be able to see that the two users were using the same device. Here is an example:

amplitude.getInstance().setUserId(null); // not string 'null'
amplitude.getInstance().regenerateDeviceId();
[[Amplitude instance] setUserId:nil]; // not string nil
[[Amplitude instance] regenerateDeviceId];
Amplitude.getInstance().setUserId(null);
Amplitude.getInstance().regenerateDeviceId();

Updated 5 months ago


Setting Custom User IDs


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.