Linking Contacts
Use the following methods to identify users in SAP Engagement Cloud. Typically called during login and logout, but can be used independently.
Linking a Contact
After the SDK is initialized and enabled, call the link method to identify the user with a contactFieldValue.
Without a linked contact, tracked events are attributed to an anonymous contact (if anonymous tracking is enabled).
- Android
- Kotlin Multiplatform
- iOS
- Web
EngagementCloud.contact.link(contactFieldValue)
EngagementCloud.contact.link(contactFieldValue)
await EngagementCloud.shared.contact.link(contactFieldValue: <String>)
await window.EngagementCloud.contact.link(contactFieldValue);
contactFieldValueis the contact identifier as astring
linkAuthenticated
After the SDK is initialized and enabled, call the linkAuthenticated method to identify the user with an openIdToken.
For more information, see OpenID Connect.
- Android
- Kotlin Multiplatform
- iOS
- Web
EngagementCloud.contact.linkAuthenticated(openIdToken)
EngagementCloud.contact.linkAuthenticated(openIdToken)
await EngagementCloud.shared.contact.linkAuthenticated(openIdToken: <String>)
await window.EngagementCloud.contact.linkAuthenticated(openIdToken);
openIdTokenis thestringvalue of the OpenID token
Unlinking a Contact
Call unlink to return the user to an anonymous state.
- Android
- Kotlin Multiplatform
- iOS
- Web
EngagementCloud.contact.unlink()
EngagementCloud.contact.unlink()
await EngagementCloud.shared.contact.unlink()
await window.EngagementCloud.contact.unlink();
Identity Strategy
| Approach | Use Case |
|---|---|
| Plain link (contactFieldValue) | Basic identification |
| Authenticated link (OpenID) | Strongly verified identity and session security |
| Unlink | Logout, consent revocation, user switch |
When to Link a Contact
- Immediately after login, so subsequent events are attributed to the contact profile.
- After calling
enable. Events tracked before linking are queued and attributed once the contact is linked.
Effects of Unlinking
- Future events become anonymous.
- Previously sent events retain prior contact attribution and cannot be anonymized retroactively. For deletion requests, contact support.
Error Handling Examples
- Android
- Kotlin Multiplatform
- iOS
- Web
EngagementCloud.contact.link(value).onFailure { e -> logger.error("Link failed", e) }
EngagementCloud.contact.link(value).onFailure { e -> logger.error("Link failed", e) }
do { try await EngagementCloud.shared.contact.link(contactFieldValue: value) } catch { print(error) }
try { await window.EngagementCloud.contact.link(value); } catch(e){ console.error(e); }
OpenID Token Rotation
When the token expires:
- Fetch the new OpenID token.
- Call
linkAuthenticated(newToken). - Verify that the SDK is using the new token.
Privacy Notes
- Avoid embedding full email or personally identifiable information in logs. Mask values instead.
- Use authenticated links for actions that require secure identity.