appendOrCreateContact( )

Appends contactInfo to an existing contact or creates a new contact if it doesn't already exist.

The appendOrCreateContact() function returns a Promise that resolves to a contact ID and identity type when a contact is found or created.

When called, appendOrCreateContact() accepts an object with contact information and follows the steps below. When one of the conditions is met, this process ends and the specified data is handled:

  1. If the current visitor is a logged-in member: appendOrCreateContact() reconciles with the member's associated contact.
  2. If the current visitor is not a logged-in member: appendOrCreateContact() tries to reconcile any specified email addresses and/or phone numbers with an existing contact.
  3. If an email address, phone number, and/or name has been provided, but the contact can't be reconciled: A new contact is created and appendOrCreateContact() reconciles with the new contact.
  4. If a contact can't be reconciled by email or phone and a new contact isn't created: appendOrCreateContact() tries to reconcile the visitor's session identity with an existing contact.
  5. If no contact can be created: The Promise is rejected.

appendOrCreateContact() does not require member authentication, so it does not return the entire contact object. The contact's data can be retrieved with getContact().

How the Data is Handled

If an existing contact is found:

  • The current visitor's session identity is associated with the contact.
  • If a specified property is empty in the existing contact, the property is updated with the specified information.
  • For arrays, any specified information is added as new array items. This includes emails, addresses, phones, and labelKeys.
  • No existing data is overwritten or deleted.

Note: If the reconciled contact belongs to a member who isn't currently logged in to the site, identityType is returned as "NOT_AUTHENTICATED_MEMBER". In that case, no contact properties are modified.

If a new contact is created:

  • The new contact's data is populated with the specified contact object.
  • The current visitor's session identity is associated with the contact.
Method Declaration
Method Parameters

Contact's information. To reconcile with an existing contact, a phone or email must be provided, or the current session identity must be attached to a contact or member.

If no existing contact can be found, a new contact is created with the specified information.

Return Type:Promise<ContactIdentification>
Was this helpful?