A user ID is used by Elevar to help stitch a session for different channels shopper journey. Elevar’s user ID is used by default which utilizes the following

  1. Shopify’s long-lived server-set cookie
  2. Device fingerprinting that doesn’t rely on cookies

Asynchronous Example

For special circumstances, you can provide your own function by doing the following:

const getMyUserId = () => Promise.resolve("my_custom_user_id");

window.ElevarUserIdFn = async () => {
    const userId = await getMyUserId();
    return userId;
}

When any data layer event is pushed, this user ID will be used.

console.log(dataLayer[dataLayer.length - 1].marketing.user_id);
// logs my_custom_user_id

Synchronous Example

For special circumstances, you can provide your own function by doing the following:

const getMyUserId = () => "my_custom_user_id";

window.ElevarUserIdFn = () => {
    const userId = getMyUserId();
    return userId;
}

When any data layer event is pushed, this user ID will be used.

console.log(dataLayer[dataLayer.length - 1].marketing.user_id);
// logs my_custom_user_id