Skip to main content
All CollectionsCreating ExperiencesTarget
How to show Experiences to visitors?
How to show Experiences to visitors?

Learn how to show in-product experiences to visitors and anonymous users

Chameleon Team avatar
Written by Chameleon Team
Updated over 2 months ago

When installing Chameleon, there are two components that need to be implemented: 

  1. The Chameleon code snippet (to load the builder and Experiences).

  2. The Identify method (to identify users).

We ask developers to identify users by their database ID. This stable identifier ensures that a user sees tours consistently (for example, resuming on the correct step if they leave and return).

For users that don't have a logged-in identity (e.g. visitors), we recommend generating a unique ID and storing it to a cookie, from which it will be read afterward.

This can be achieved, for example, by using the following code between the Chameleon code snippet and the Chameleon identify method. 

/* chmln code snippet */

if(user is not logged-in) { var uid;
  try { uid = document.cookie.match(/\bvisitor-uid=([a-z0-9-]+)(;|$)/)[1]; } catch(e) {
    document.cookie = 'visitor-uid='+(uid = Math.random().toString(36).substring(2))+'; expires=Tue, Oct 13 2037 04:24:07 UTC; path=/;';
  }

  chmln.identify(uid, { visitor: true });
}

/* normal chmln.identify with user.id */


Identifying anonymous users to Chameleon will also represent an impact on your MTU count since each anonymous session is counted as an additional user.

Moreover, the generated anonymous ID is stored in a cookie, which is likely session-based, and users can clear their browser data -- thus giving an inconsistent perception of the actual users that are engaging with Chameleon Experiences.


Explore more

Did this answer your question?