> For the complete documentation index, see [llms.txt](https://docs.ecwid.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ecwid.com/storefronts/track-storefront-events/customer-logged-in-event.md).

# "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
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.ecwid.com/storefronts/track-storefront-events/customer-logged-in-event.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.
