Visitor IDs will be randomly generated the first time a recording takes place.

However, if your website collects users' details (e.g., when they log in, etc.), these identifying characteristics can be parsed into Smartlook via our identify API.

Setting up visitor identification consists of 2 parts: activating the feature within project settings and code implementation on your website.
Smartlook settings
Select the project and toggle on the Identify users via API button.

Technical implementation
The identify
method requires you or your developer to propagate the information from your service. This method will be called from the browser of your visitor, therefore, any information you want to associate with your visitors, needs to be part of your web page.
Visitor information
The following example presents the simplest usage of the identify
method. The example expects there is a user_id
variable that is identifying your visitor. Code you'll need to insert into your website has the following format in JavaScript:
<script>
smartlook('identify', user_id);
</script>
User ID is a unique number or string used to identify a specific user.
The following example assumes you're using a template used for rendering the final HTML, in which you can pass in the information of a current visitor. Pairing your visitor with your internal identifier will enable you to find this user in Smartlook by this identifier.
UID | NAME | |
123 | John Doe |
Here is an example in PHP.
echo "<script>";
echo "smartlook('identify', '{$user->id}');";
echo "</script>";
In your website, the following code will be generated in JavaScript:
<script>
smartlook('identify', '123');
</script>
More visitor details
In addition to basic information shown on the dashboard, you can also identify your users with their email, name, or any other property—there's no limit to what you can display on the dashboard. It could be a name or an 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. The expectation will be it concerns an object. The keys of this object are entirely up to you, as well as all the values.
Feel free to modify the code and expand it to your own needs, as you can see in an example below:
<script>
smartlook('identify', uid, {
"name": "John Doe",
"email": "john.doe@example.com",
"package": "Premium",
"currency": "USD",
"cost": 150
});
</script>
You can find additional technical information in our Identify visitor documentation.