How to implement the Userlane snippet

What is the Userlane Snippet?

The Userlane Snippet is a JavaScript code that needs to be implemented by your engineers into the source code of your application. After this implementation, Userlane will be shown to your users.

Software providers can onboard users and increase retention for their applications. A requirement to implement the snippet is the ability to deploy custom JavaScript in the application. Userlane can then be directly implemented via the Userlane snippet in the application’s code. The browser extension can still be used in the early stages to build and test your first Guides.

Benefits of implementing the Snippet

Userlane will be shown in the application independent of the browser and is available to all end-users. 

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. A custom attribute could be a user role or a subscription to a specific feature of your application.  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. Here you’ll find further information on user-based segmentation

// 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.