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 visitorId is automatically sent when fetching messages for an anonymous user.
  • Once a user logs in and you identify them with a customerId (using setUserId), the SDK will only use the customerId to fetch messages from that point on.
⚠️

Important Consideration

Because the visitorId is no longer used after login, any messages that were targeted only to the user's visitorId will 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.

Using the Launcher Badge for Visitors

By default, the launcher badge component will only appear if two conditions are met:

  1. The badge is enabled in your Inbox Settings.
  2. 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 visitorId from 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();