How to implement the Userlane snippet

This article describes the steps required to implement the different parts of the Userlane snippet into your application code.

Userlane Admin task
Share the snippet with your developers 

To locate the Userlane snippet, select Settings from your application dropdown, then select Setup in the left sidebar menu. Copy the snippet and send it to your developers.

The snippet makes Userlane visible for your end users. You can simply set all chapters to private or switch Userlane off under General Settings to ensure that none of your users sees Userlane before go-live.

If you already have a Userlane Account and you would like to see this interactively:

Developer tasks
1. Implement the snippet

The load function loads Userlane in your application. The initialize command executes Userlane and is needed for the Userlane Assistant to appear. The Snippet should be implemented into the application's front-end, before the closing </body> tag.

// load Userlane

// identify your user (see Chapter 3. below)


// initialize Command

Userlane('init', your_property_ID);

Make sure that the initialize command contains your account’s property ID that can be found in the Userlane Portal snippet. The initialize command executes Userlane. Therefore, all the commands that you want to additionally use should be called before ‘init’.

ℹ️  You need to load and initialize Userlane to make it visible in your application. Any other commands are optional.

2. Add additional user information in your code snippet

We recommend that you add the user ID in your snippet with the identify command so that Userlane can save the status of a user anonymously. 

// Pass the user ID without any Custom User Attributes


ℹ️  We recommend that you use the user ID in the identify command as well. Keep in mind that if this command is not used, Userlane will generate a random user ID and will save it in a cookie.

Additionally, you can add Custom User Attributes within this command. This allows applying user-based segmentation in the Userlane Portal later. This article provides more info on how a snippet with passed custom data attributes looks. 

// Pass a Custom User Attribute (data types: number, string, datetime, array, boolean)


ℹ️  If any additional commands are added in the snippet, make sure they are called before the initialize command. The initialize command confirms the passed user information. Therefore, whenever the page is reloaded, the passed user information is refreshed.

User Icon

Thank you! Your comment has been submitted for approval.