> For the complete documentation index, see [llms.txt](https://docs.userlane.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.userlane.com/developers/userlane-commands/quick-reference-of-commands.md). Agents can also search and read this documentation through its [MCP server](https://docs.userlane.com/~gitbook/mcp).

# Quick reference of commands

The most common JavaScript commands in one place: load, identify, initialize, open the Assistant, hide, remove, language, start, and callbacks.

Commands issue instructions to Userlane from application code. Each section below links to the article that covers that command in more depth.

## Load the script

Covered in How Userlane is deployed.

```js
// load Userlane
(function(i,s,o,g,r,a,m){i['UserlaneCommandObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)};a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','https://cdn.userlane.com/userlane.js','Userlane');
```

## Identify the user

Covered in Attributes.

```js
// identify command
Userlane('identify', currentUser.id);
```

## Identify the user and pass custom attributes

Covered in Attributes.

```js
// identify command with custom user attributes
Userlane('identify', currentUser.id, {
    attribute_key: 'attribute_value',
});
```

## Initialize Userlane

Covered in How Userlane is deployed.

```js
// initialize command
// replace YOUR_PROPERTY_ID with the property ID
Userlane('init', 'YOUR_PROPERTY_ID');
```

## Open the Assistant

Covered in [Implement a command to open the Assistant](https://docs.userlane.com/developers/userlane-commands/open-the-assistant.md).

```js
// open the Assistant
Userlane('openAssistant');
```

## Hide Userlane

Covered in [Hide Userlane on specific pages](https://docs.userlane.com/developers/userlane-commands/hide-userlane-on-specific-pages.md).

```js
// hide Userlane
// call it after the init command, and again on each page load
Userlane('hide');

// show Userlane again by initializing it
// replace YOUR_PROPERTY_ID with the property ID
Userlane('init', 'YOUR_PROPERTY_ID');
```

## Remove Userlane

Removes Userlane from the page completely. After this command `Userlane` is no longer defined on the page, so any further command throws an error. Userlane is available again after the page is reloaded.

```js
// remove Userlane
Userlane('removeUserlane');
```

## Set the language

Covered in [Userlane language detection](https://docs.userlane.com/developers/userlane-commands/language-detection.md).

```js
// set the language of Userlane
Userlane('lang', 'language_code');
```

## Start a Guide

Covered in [Start a Guide with a JavaScript command](https://docs.userlane.com/developers/userlane-commands/start-a-guide-with-javascript.md).

```js
// start a Guide
// replace 12345 with the Guide ID
Userlane('start', '12345');

// start a Guide at a specific step
// replace 12345 with the Guide ID
// replace 4 with the index of the step
Userlane('start', '12345', 4);

// start a Guide only once per user
// replace 12345 with the Guide ID
Userlane('startOnce', '12345');
```

## Callback events

Covered in [Hooking into event callbacks](https://docs.userlane.com/developers/userlane-commands/event-callbacks.md).

```js
// hook into onStart, onComplete or onExit and provide a callback function
// optionally replace onStart with onComplete or onExit
Userlane('onStart', function (userlaneId, user) {
    // any code can go here
    console.log('the user started a Guide');
});

// remove the callback from the onStart event
Userlane('onStart', false);
```

Example user object passed to the callback:

```js
{
    id: '9717166719265375',
    generated: true,
    time_signup: '2017-11-22T11:50:48.671Z'
}
```

## Relevant articles

* How Userlane is deployed
* [Implement a command to open the Assistant](https://docs.userlane.com/developers/userlane-commands/open-the-assistant.md)
* [Hide Userlane on specific pages](https://docs.userlane.com/developers/userlane-commands/hide-userlane-on-specific-pages.md)
* [Start a Guide with a JavaScript command](https://docs.userlane.com/developers/userlane-commands/start-a-guide-with-javascript.md)
* [Hooking into event callbacks](https://docs.userlane.com/developers/userlane-commands/event-callbacks.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.userlane.com/developers/userlane-commands/quick-reference-of-commands.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
