Skip to main content

All about User IDs

For all API calls, you need to pass two kinds of user identification parameters.

Parameter: user_id#

user_id is the ID associated with a logged in user on your website or app.


If your user_id is a PII, in keeping up with our GDPR guidelines, make sure you hash it before you pass it in the APIs. If you use our script, our customer delivery team will also check with you during the time of onboarding and setup config to always hash the user_id before accessing it.

Parameter: mad_uuid#

mad_uuid is a unique ID associated to the particular user session and stored in cookies.

For No Code integration mode, generating the mad_uuid, storing and accessing it is taken care of by us.

Set and Get mad_uuid#

For API Integration mode, you need to explicitly generate the UUID and persist in the cookie for the user session. This cookie need to be set with an expiry of 365 days.

Sample code to generate UUID

let MADid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {    const r = Math.random() * 16 | 0;    const v = c == 'x' ? r : (r & 0x3 | 0x8);    return v.toString(16);});

Persist MADid in cookies.

function MSDsetCookie(name, value, days, path) {    const date = new Date();    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));    const expires = `; expires=${date.toGMTString()}`;    document.cookie = `${name}=${value}${expires}; path=${path}`;  }    MSDsetCookie('MADid', value, 365, '/') 

Sample code to read from cookie

function msdReadCookie(cookieName) {    const theCookie = `${document.cookie}`;    const index     = theCookie.indexOf(cookieName);
    if (index == -1 || cookieName == '') {       return '';    }
    let indexOfSemiColon= theCookie.indexOf(';', index);
    if (indexOfSemiColon == -1) {       indexOfSemiColon = theCookie.length;    }
    let cookieValue = theCookie.substring(index + cookieName.length + 1,  indexOfSemiColon)
    return unescape(cookieValue);}
let MADid = msdReadCookie("MADid");

Get mad_uuid from Embed Code#

For Mixed Integration mode, mad_uuid is generated by the script and stored in the cookie. You would need to access the mad_uuid to be sent in the search and recommendation APIs.

Sample code to fetch the mad_uuid:

let mad_uuid = msdReadCookie('MADid');