Identifying Users

Learn about the types of user IDs used by Flike.

Personalized recommendations only work when we know who we're personalizing for! But since users are not always logged in when they interact with your product, knowing which identifier to use as user ID can be a bit tricky. This guide shows you what identifier to use in which situation, and where you can typically find these identifiers.

In general, Flike considers two types of user identifiers:

  • The persistent user ID. This is the ID you use in your internal database, such as a UUID for each user. You should set these IDs in your analytics tools (see below).
  • The semi-persistent anonymous ID. This is a generated ID for users who are not logged in, and hence anonymous. Flike automatically merges anonymous IDs into the persistent user ID upon login.

When requesting recommendations, you should use the persistent user ID if available, and otherwise fall back to the user's anonymous ID. You can get this ID from your analytics tool as shown below.

Integrating with your Analytics Tool


Segment's client libraries automatically generate an anonymousId. You can retrieve (and set) this id using the client library, e.g. using analytics.user().anonymousId(); in JavaScript.

When a user logs in, you should set the user ID by sending an identify event with the appropriate userId as documented in the segment spec. For example, in the segment JavaScript library, you can call the analtyics.identify method as follows:

analytics.identify('<your user ID>', {
  // ... any relevant user attributes


Amplitude generates semi-persistent device IDs, which serve as anonymous IDs. To stick with our running example, in the client-side JavaScript library you would retrieve this ID using amplitude.getInstance().getDeviceId().

When a user logs in, you should pass the appropriate user ID to amplitude. In JavaScript, you can do this by calling amplitude.getInstance().setUserId('<your user ID>');.

Google Analytics

Google Analytics generates a client ID upon page load. The methods for retrieving this ID depend on your version of Google Analytics:

  • In Google Analytics 4 or Universal Analytics with gtag.js, you can use the following code snipped to get the client ID:
    window.dataLayer.push(function () {
      let clientId = this.get('clientId')
  • In the legacy Universal Analytics with analytics.js, you can use the following code snippet to get the client ID: => {
      let clientId = tracker.get('clientId')

When a user logs in, you should pass the appropriate user ID to Google Analytics by sending a config event as follows:

gtag('set', 'user_id', '<your user ID>');

Did this page help you?