> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pyne.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect User Data

> Integrating user data for targeting in Pyne

To target guides effectively using [Targeting Rules](/setup/targeting), you need to send user data (attributes or traits) to Pyne. This allows you to define audiences based on user characteristics.

<Note>
  We can help you identify the most useful user attributes during your
  onboarding/kickoff call.
</Note>

There are two main ways to connect user data:

## Option 1: Segment Integration (Recommended)

If you use Segment, Pyne offers a custom destination.

* **Setup:** Contact the Pyne team to enable the destination for your Segment workspace.
* **Functionality:** Pyne automatically receives user traits identified via Segment, making them available for targeting.
* **Effort:** Minimal setup required on your end (approx. 15 min).

<div style={{ position: "relative", paddingBottom: "56.25%", height: 0 }}>
  <iframe
    src="https://www.loom.com/embed/9165376ef92346878cec2fa79118b591"
    frameborder="0"
    webkitallowfullscreen
    mozallowfullscreen
    allowfullscreen
    style={{
  position: "absolute",
  top: 0,
  left: 0,
  width: "100%",
  height: "100%",
}}
  />
</div>

## Option 2: JavaScript Integration (`pyne.identify`)

If you don't use Segment, you can send user data directly using the `pyne.identify` JavaScript function.

**Basic Usage:**

Call `pyne.identify` when a user logs in or when their relevant attributes are known. Provide a unique User ID and an object containing the user's traits.

```javascript theme={null}
// Identify the user and their properties
pyne(
  "identify",
  currentUser.id, // Unique User ID (string or number)
  {
    // User Properties (object)
    name: currentUser.name,
    email: currentUser.email,
    created_at: currentUser.created_at, // Use ISO-8601 format if possible
    customer_plan: "trial",
    user_role: "admin",
    // Add any other relevant traits
  }
);
```

<Note>
  * Call `identify` once per page load after the user is authenticated. It's
    safe to call multiple times. \* User traits sent via `identify` are merged with
    any existing profile data in Pyne. \* This step is not required for anonymous
    (unidentified) visitors.
</Note>

**Ending a Session (Logout):**

When a user logs out, call `identify` with `null` to clear the identified user session:

```javascript theme={null}
pyne("identify", null);
```

**Removing a Specific Trait:**

To remove or unset a specific trait, send `undefined` as its value:

```javascript theme={null}
pyne("identify", currentUser.id, {
  customer_plan: undefined,
});
```

## Verify Integration

After setting up either integration method, verify that user data is appearing correctly in the Pyne Dashboard:

1. Navigate to **People**.
2. Check if users are listed and their associated traits are visible when selecting a user.

You can view these traits on the **People** page in the Pyne dashboard:

<img src="https://mintcdn.com/pynegmbh/kQ-U5xvcWyOX7gqR/assets/images/people.png?fit=max&auto=format&n=kQ-U5xvcWyOX7gqR&q=85&s=089a9f27c09f44a41eef34e223f617b6" alt="People page" width="2046" height="758" data-path="assets/images/people.png" />

Clicking on a user shows their specific traits:

<img src="https://mintcdn.com/pynegmbh/kQ-U5xvcWyOX7gqR/assets/images/people-traits.png?fit=max&auto=format&n=kQ-U5xvcWyOX7gqR&q=85&s=25f6933bee7e82d4404b72cb1aab800d" alt="User traits" width="2068" height="984" data-path="assets/images/people-traits.png" />

## Identifying Anonymous Users
