Supporting Visitors & Customers
Optimove's Embedded Messaging allows you to send targeted campaigns not only to your known, logged-in customers but also to anonymous first-time visitors to your site.
This is achieved by using two types of identifiers:
customerId: The unique identifier for a known customer who has logged in or registered.visitorId: A unique identifier assigned by the Optimove SDK to a user's device when they first arrive on your page.
You can set up triggered campaigns for visitors using event-based triggers, the Web SDK, and server-side events.
The "Out-of-the-Box" Experience
When using the standard, out-of-the-box UI components, the SDK automatically manages the identifiers for you. However, it's important to understand how the identifier changes upon login.
- The
visitorIdis automatically sent when fetching messages for an anonymous user. - Once a user logs in and you identify them with a
customerId(usingsetUserId), the SDK will only use thecustomerIdto fetch messages from that point on.
Important ConsiderationBecause the
visitorIdis no longer used after login, any messages that were targeted only to the user'svisitorIdwill not be visible after they identify as a customer.You should ensure your campaign targeting strategy accounts for this behavior to create a consistent user experience.
Customer Aliases
A customer in Optimove can have one or more aliases: the identifiers your site or app uses for that person. When a campaign targets a customer who has aliases, Embedded and Overlay messages are delivered to each alias rather than to the Optimove customer ID.
Important ConsiderationIf a customer has aliases, no message is published under the original customer ID. A user identified with
setUserId(<ORIGINAL_CUSTOMER_ID>)will not see these messages. CallsetUserId()with the alias your site uses for the logged-in user.
How Aliases Behave
- Delivery: Messages are published once per alias. [CONFIRM WITH PM: whether a tenant must have aliases/HashedID enabled by CSE, and how a developer can tell a tenant uses aliases]
- Read, unread and delete state: Reading, marking unread or deleting an Embedded message applies the change under every alias of the customer.
- Overlay dismissal: Dismissing an Overlay message, including a click that closes it and an interceptor
discard, applies under every alias. - Reporting: Opens and clicks are reported once, against the alias the user was identified with.
Example
// Use the alias your site uses for the logged-in user, not the Optimove customer ID
optimoveSDK.API.setUserId('<YOUR_CUSTOMER_ALIAS>');For fetching and displaying messages after the user is identified, see the Using the SDK for Embedded Messaging guide.
If you call the REST API directly (custom UI), pass the alias as the
customerIdin your requests. See the Getting Started with Embedded Messaging guide.
Using the Launcher Badge for Visitors
By default, the launcher badge component will only appear if two conditions are met:
- The badge is enabled in your Inbox Settings.
- The user is logged in (i.e., has a
customerId).
To show the badge for anonymous visitors, you must explicitly call the enableBadge() method from the SDK. This will override the default behavior and display the badge even for users who are not logged in.
optimoveSDK.API.Inbox.enableBadge();
Building a Custom UI (Direct API Integration)
If you are building your own UI and interacting with the REST API directly, you are responsible for passing the correct identifiers.
-
When fetching messages for an anonymous visitor, you must retrieve their
visitorIdfrom the SDK and include it in your API call. -
To get the user's
visitorId, use the following SDK method:optimoveSDK.API.componentsProvider.userManager.getOriginalVisitorId();
Updated 3 days ago
