# Visitor — Pass User Context

The **Pass User Context** message enables the host app / environment to pass visitor information to the LiSA Player.

{% hint style="warning" %}
Please ensure the host app / environment awaits the [App Listen](https://docs.hello-lisa.com/developers/guides/player-communication/message-api-reference/app/app-listen) message to ensure the LiSA Player is ready to accept visitor related messages.
{% endhint %}

This message is sent by the host app / environment to the LiSA Player.

### Properties

Along with all standard [Message properties](https://docs.hello-lisa.com/developers/guides/player-communication/message-api-reference/..#properties), a **Pass User Context** message includes the following additional properties:

<table><thead><tr><th width="239" valign="top">Name</th><th width="162" valign="top">Type</th><th valign="top">Description</th></tr></thead><tbody><tr><td valign="top"><code>avatarUrl</code></td><td valign="top"><pre><code>String
</code></pre><p>Optional.</p></td><td valign="top"><p>The <code>avatarUrl</code> property is used to provide a URL pointing to an image that represents the visitor's avatar. <br></p><p>Ensure the image URL points to a properly hosted and publicly accessible resource to avoid display issues.</p></td></tr><tr><td valign="top"><code>displayName</code></td><td valign="top"><pre><code>String
</code></pre><p>Optional.</p></td><td valign="top">The <code>displayName</code> property is used to specify the current visitor's display name, which will be shown in comments.</td></tr><tr><td valign="top"><code>id</code></td><td valign="top"><pre><code>String
</code></pre><p>Required.</p></td><td valign="top">The <code>id</code> property is used to define the current visitor's unique identifier within the user management system of the host app or environment. This identifier will be associated with the visitor's session in LiSA.</td></tr><tr><td valign="top"><code>isCommentsConsentRequired</code></td><td valign="top"><pre><code>Boolean
</code></pre><p>Optional.</p></td><td valign="top">This property indicates whether the visitor is required to consent to the comments policy before being allowed to post comments.<br><br>Default value: <code>true</code></td></tr><tr><td valign="top"><code>messageType</code></td><td valign="top"><pre><code>Literal
</code></pre><p>Required.</p></td><td valign="top"><code>lsc:visitor:pass-user-context</code></td></tr><tr><td valign="top"><del><code>trackingParameters</code></del></td><td valign="top"><pre><code>TrackingParameters
</code></pre><p>Optional.</p></td><td valign="top"><div data-gb-custom-block data-tag="hint" data-style="warning" class="hint hint-warning"><p><strong>Deprecated</strong> — please use <a href="player/player-deeplink-parameters">Player Deeplink Parameters</a> instead.</p></div><p>The <code>trackingParameters</code> property is an object containing extra parameters that will be appended to all social sharing URLs.</p><p></p><p>Please refer to <a href="#trackingparameters"><code>TrackingParameters</code></a> for detailed information.</p></td></tr></tbody></table>

#### Legacy Properties

{% hint style="warning" %}
If your integration uses **LiSA Player Version 1**, none of the properties described above — except `id` —  will be available.

For **LiSA Player Version 2**, legacy properties can be ignored.
{% endhint %}

<table><thead><tr><th width="239" valign="top">Name</th><th width="163" valign="top">Type</th><th valign="top">Description</th></tr></thead><tbody><tr><td valign="top"><code>action</code></td><td valign="top"><pre><code>Literal
</code></pre><p>Required.</p></td><td valign="top"><code>join</code><br><br><span data-gb-custom-inline data-tag="emoji" data-code="26a0">⚠️</span> Please use <code>messageType</code> instead.</td></tr><tr><td valign="top"><code>avatar</code></td><td valign="top"><pre><code>String
</code></pre><p>Optional.</p></td><td valign="top"><p>The <code>avatar</code> property is used to provide a URL pointing to an image that represents the visitor's avatar. <br></p><p>Ensure the image URL points to a properly hosted and publicly accessible resource to avoid display issues.<br><br><span data-gb-custom-inline data-tag="emoji" data-code="26a0">⚠️</span> Please use <code>avatarUrl</code> instead.</p></td></tr><tr><td valign="top"><code>consent</code></td><td valign="top"><pre><code>Boolean
</code></pre><p>Optional.</p></td><td valign="top">This property indicates whether the visitor is required to consent to the comments policy before being allowed to post comments.<br><br>Default value: <code>true</code><br><br><span data-gb-custom-inline data-tag="emoji" data-code="26a0">⚠️</span> Please use <code>isCommentsConsentRequired</code> instead.</td></tr><tr><td valign="top"><code>editable</code></td><td valign="top"><pre><code>Boolean
</code></pre><p>Optional.</p></td><td valign="top">This property indicates whether the visitor can edit their username in the comments.<br><br>Default value: <code>true</code><br><br><span data-gb-custom-inline data-tag="emoji" data-code="26a0">⚠️</span> This property is no longer supported in Player Version 2.</td></tr><tr><td valign="top"><code>name</code></td><td valign="top"><pre><code>String
</code></pre><p>Optional.</p></td><td valign="top">The <code>name</code> property is used to specify the current visitor's display name, which will be shown in comments.<br><br><span data-gb-custom-inline data-tag="emoji" data-code="26a0">⚠️</span> Please use <code>displayName</code> instead.</td></tr><tr><td valign="top"><code>target</code></td><td valign="top"><pre><code>Literal
</code></pre><p>Required.</p></td><td valign="top"><code>user</code><br><br><span data-gb-custom-inline data-tag="emoji" data-code="26a0">⚠️</span> Please use <code>messageType</code> instead.</td></tr></tbody></table>

***

### Type Definition

```typescript
interface VisitorUserContextMessage extends Omit<
  Message,
  'messageType' | 'recipient'
> {
  avatarUrl?: string;
  displayName?: string;
  id: string;
  isCommentsConsentRequired?: boolean;
  recipient: 'LiSA';
  messageType: 'lsc:visitor:pass-user-context';
  /**
   * @deprecated - Please use [Player Deeplink Parameters](https://docs.hello-lisa.com/developers/guides/player-communication/message-api-reference/player/player-deeplink-parameters) instead.
   */
  trackingParameters?: TrackingParameters;

  // Legacy LiSA Player V1 attributes for backwards compatibility. 

  action: 'join';
  avatar?: string;
  consent?: boolean;
  editable?: boolean;
  name?: string;
  target: 'user';
}
```

***

#### `TrackingParameters`

The `TrackingParameters` object lets you include custom parameters in the player, which will be appended to all social sharing URLs.

{% hint style="warning" %}
**Please note:** Any value of type other than `number` or `string` will be ignored.
{% endhint %}

```typescript
interface TrackingParameters {
  [key: string]: number | string;
}
```

### Example

```javascript
window.postMessage({
  avatarUrl: 'https://my-cdn.com/path/to/image.jpg',
  displayName: 'Jane Doe',
  id: '65cf573a-8c51-4b89-b2da-3d79b35fcf1b',
  isCommentsConsentRequired: false,
  recipient: 'LiSA',
  sender: 'Sender',
  messageType: 'lsc:visitor:pass-user-context',
  
  // Depracated - Please use Player Deeplink Parameters instead
  trackingParameters: {
    utm_campaign: 'spring-sale',
    utm_content: 'social-sharing',
    utm_source: 'lisa-social-commerce',
  },

  // Legacy properties - Can be omitted when integrating Player V2
  action: 'join',
  avatar: 'https://my-cdn.com/path/to/image.jpg',
  consent: true,
  editable: false,
  name: 'Jane Doe',
  target: 'user',
});
```
