# "Customer logged in" event

### `Ecwid.OnSetProfile`

This method allows you to track a moment when customers log in and out on the storefront.&#x20;

It contains a callback function with `customer` [argument](#page-argument-fields) when a customer logs in, and `null` if a customer has logged out.

Code example:

```javascript
Ecwid.OnSetProfile.add(function(customer){
	console.log(customer.email);
})

// prints
// "ec.apps@lightspeedhq.com"
```

#### `customer` argument fields:

<table><thead><tr><th width="197">Field</th><th width="181">Type</th><th>Description</th></tr></thead><tbody><tr><td>email</td><td>string</td><td>Customer's email.</td></tr><tr><td>id</td><td>number</td><td>Customer's internal ID.</td></tr><tr><td>membership</td><td>object <a href="#membership">membership</a></td><td>Customer's group information.<br><br>If customer belongs to a general group, this field is omitted from the callback. </td></tr><tr><td>ownerId</td><td>number</td><td>Internal store ID.</td></tr><tr><td>registered</td><td>string</td><td>Customer's registration date in a stringified UNIX timestamp format. <br><br>For example, <code>"1718010611"</code>.</td></tr><tr><td>billingPerson</td><td>object <a href="#billingperson">billingPerson</a></td><td>Customer's saved billing address.</td></tr><tr><td>shippingAddresses</td><td>array of objects <a href="#shippingaddresses">shippingAddresses</a></td><td>Customer's saved shipping addresses.</td></tr></tbody></table>

#### billingPerson

<table><thead><tr><th width="217">Field</th><th width="140">Type</th><th>Description</th></tr></thead><tbody><tr><td>name</td><td>string</td><td>Full name of the customer.</td></tr><tr><td>companyName</td><td>string</td><td>Customer's company name.</td></tr><tr><td>street</td><td>string</td><td>Address line 1 and address line 2, separated by <code>\n</code>.</td></tr><tr><td>city</td><td>string</td><td>City.</td></tr><tr><td>countryCode</td><td>string</td><td>Two-letter country code.</td></tr><tr><td>countryName</td><td>string</td><td>Country name.</td></tr><tr><td>postalCode</td><td>string</td><td>Postal/ZIP code.</td></tr><tr><td>stateOrProvinceCode</td><td>string</td><td>State/province code, for example, <code>NY</code>.</td></tr><tr><td>phone</td><td>string</td><td>Customer's phone number.</td></tr></tbody></table>

#### shippingAddresses

<table><thead><tr><th width="130">Field</th><th width="200">Type</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td>number</td><td><p>Ordered ID of saved shipping address.<br></p><p>Starts with <code>0</code> and iterates by <code>1</code>.</p></td></tr><tr><td>person</td><td>object <a href="#billingperson">billingPerson</a></td><td>Details of the saved shipping address.</td></tr></tbody></table>

#### membership

<table><thead><tr><th width="130">Field</th><th width="200">Type</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td>number</td><td>Customer group's ID.</td></tr><tr><td>name</td><td>string</td><td>Name of the customer group.</td></tr><tr><td>ownerId</td><td>number</td><td>ID of the store customer group belongs to.</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ecwid.com/storefronts/track-storefront-events/customer-logged-in-event.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
