# Contact Profiles

Using Bird SDKs in your applications, you can identify the user as a *contact* in BirdCRM.

## Anonymous Contact

When the web or mobile application starts, it already creates an anonymous contact. Having this anonymous contact is useful to support [Push Notifications](https://docs.bird.com/api/client-sdks/push-notifications) even before any user logs in.

Example use cases:

* You get insights on which pages anonymous users visit or which products they put in their cart.
* You can send a push notification campaign to all anonymous contacts.
* You can build a journey to send Push Notifications to anonymous users who abandoned their carts to remind them to checkout.

## Providing Contact Identifier

When the user logs in on your website or mobile app, you can identify the user with a unique identifier from your system. For example, the `userId` could be used in this case.

Here how to provide a contact identifier:

{% tabs %}
{% tab title="Android (Kotlin)" %}

```kotlin
bird.contact.identify( ExternalIdentifier("external_id", userId) )
```

{% endtab %}

{% tab title="iOS (Swift)" %}

```swift
bird.contact.identify(externalid: userId)
```

{% endtab %}

{% tab title="Web (Js)" %}

<pre class="language-javascript"><code class="lang-javascript">// Identify as anonymous visitor
await Bird.contact.identify({ strategy: 'Visitor' });

<strong>// Or identify with a known identifier
</strong>await Bird.contact.identify({
  strategy: 'Visitor',
  identifier: {
    key: 'emailaddress',
    value: 'user@email.com',
  },
});
</code></pre>

{% endtab %}
{% endtabs %}

### Signed Identity

Signed Identity is a more secure way to provide contact identifiers. When the user logs in on your website or mobile app, your backend server will return a signed payload containing the identifiers for this user. This signed payload is called `SignedIdentity`. Take a look at the following sequence diagram:

<figure><img src="https://3210271997-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdnJZeZvhOMhDQA8SpjQM%2Fuploads%2FkEcNjKhe1CpWyndl1bRs%2FScreenshot%202024-06-18%20at%2011.16.41.png?alt=media&#x26;token=a7a8630e-c454-4a17-83d4-6fcf321a403e" alt="" width="375"><figcaption></figcaption></figure>

Here is how this sequence look like in code on the client application:

{% tabs %}
{% tab title="Android (Kotlin)" %}

```kotlin
// Call backend server for user login
val response = userLogin()

// and get signed identity
val signedIdentity = response.signedIdentity

bird.contact.identify( SignedIdentity(signedIdentity) )
```

{% endtab %}

{% tab title="iOS (Swift)" %}

```swift
// Call backend server for user login
let response = userLogin()

// and get signed identity
let signedIdentity = response.signedIdentity

bird.contact.identify(signedIdentity: signedIdentity)
```

{% endtab %}

{% tab title="Web (Js)" %}

```javascript
// Call your authenticated backend to get a signed identity
// Your backend must verify the user's session before issuing the JWT
const resp = await fetch('/api/bird-identity', {
  method: 'POST',
  credentials: 'include', // sends session cookies for authentication
});
const { signedIdentity } = await resp.json();

await Bird.contact.identify({
  strategy: 'SignedIdentityClaims',
  signedIdentity: signedIdentity,
});
```

{% endtab %}
{% endtabs %}

Read more about how to [generate Signed Identity](https://docs.bird.com/api/client-sdks/contact-profiles/signed-identity).

## Contact Attributes

You can add any user properties as attributes on the contact. This allows you to create audiences by filtering on those attributes.

{% tabs %}
{% tab title="Android (Kotlin)" %}

```kotlin
val attributes = Attributes()
    .put("displayName", name)
    .put("subscribedPush", true)
    .put("subscribedAppInbox", true)
bird.contact.putAttributes(attributes)
```

{% endtab %}

{% tab title="iOS (Swift)" %}

```swift
let attributes = BirdKit.Attributes()
                     .put("displayName", name)
                     .put("subscribedPush", true)
                     .put("subscribedAppInbox", true)
bird.contact.putAttributes(attributes: attributes)
```

{% endtab %}

{% tab title="Web (Js)" %}

```javascript
await Bird.contact.putAttributes({
  displayName: name,
  subscribedPush: true,
  subscribedAppInbox: true,
});
```

{% endtab %}
{% endtabs %}
