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 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:
Exemple de code
bird.contact.identify( ExternalIdentifier("external_id", userId) )Exemple de code
bird.contact.identify(externalid: userId)Exemple de code
// Identify as anonymous visitor
await Bird.contact.identify({ strategy: 'Visitor' });
// Or identify with a known identifier
await Bird.contact.identify({
strategy: 'Visitor',
identifier: {
key: 'emailaddress',
value: 'user@email.com',
},
});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:
Here is how this sequence look like in code on the client application:
Exemple de code
// Call backend server for user login
val response = userLogin()
// and get signed identity
val signedIdentity = response.signedIdentity
bird.contact.identify( SignedIdentity(signedIdentity) )Exemple de code
// Call backend server for user login
let response = userLogin()
// and get signed identity
let signedIdentity = response.signedIdentity
bird.contact.identify(signedIdentity: signedIdentity)Exemple de code
// 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,
});Read more about how to generate 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.
Exemple de code
val attributes = Attributes()
.put("displayName", name)
.put("subscribedPush", true)
.put("subscribedAppInbox", true)
bird.contact.putAttributes(attributes)Exemple de code
let attributes = BirdKit.Attributes()
.put("displayName", name)
.put("subscribedPush", true)
.put("subscribedAppInbox", true)
bird.contact.putAttributes(attributes: attributes)Exemple de code
await Bird.contact.putAttributes({
displayName: name,
subscribedPush: true,
subscribedAppInbox: true,
});