Visitor names and IDs are randomly generated the first time a recording takes place.

However, if your website contains a database of users, these identifying characteristics can be parsed into Smartlook via our API.

Developer needed: The identify method requires you or your developer to propagate the information from your service. This method is called from the browser of your visitor, therefore any information you want to associate with your visitor needs to be part of your web page.

Visitor information

Following example presents the simplest usage of identify method. The example expects there is an user_id variable that is identifying your visitor. Code you need to insert in your site has a following format in JavaScript:

  smartlook('identify', user_id);

User ID is unique number or string used to identify your user.

Following example assumes you are using a template used for rendering the final HTML in which you can pass in the information of current visitor. Pairing your visitor with your internal identifier enables you to find this user in Smartlook by this identifier.


Here is an example in PHP.

echo "<script>"; 
echo "smartlook('identify', '{$user->id}');";
echo "</script>";

In your site following code will be generated in JavaScript.

  smartlook('identify', '123');

More visitor details:

In addition to basic info shown in dashboard you can also identify your users with their email, name or any other property -there is no limit to what you display in dashboard. It could be name or email, but also what package the user bought, what currency, price, brand, size - or any other important property in your database.

The third parameter of the identify method is optional. It is expected to be an object. The keys of this object are entirely up to you, as well as all of the values.

Feel free to modify the code and expand it to your needs as you can see in an example below.

  smartlook('identify', uid, {
    "name": "John Doe",
    "email": "",
    "package": "Premium",
    "currency": "USD",
    "cost": 150

Anonymize user

You can anonymize previously identified users by calling


New visitor with new session will be created. This method is useful to call when multiple people are using the same browser (typically after logout).

Final notes

Following section is applicable to those using Smartlook within static website.

The identify method should always be called after Smartlook Web SDK is initialized.

If you are integrating your Smartlook Web SDK within the <head></head> section of your site, the actual identify call should just before the closing </body> tag.

You need to propagate your data into the HTML that is sent to your client. The identify call is done on the client and your data can only be passed to Smartlook when they are part of your HTML.

Did this answer your question?