Can I use Iridize even if a user is not logged in?

Yes.

While you can embed Iridize on any web page, this issue is normally raised by our customers when they want to take advantage of the user activation conditions even before a user login. For example, to show an overview video to a user only once.

When you embed Iridize you can read/write a random user_id from a cookie or local storage.

To do so, please replace the following line in the embed code:

iridize("api.fields.set",{user_id:"LOGGED_IN_USER_ID_GOES_HERE",joined_at:UNIXEPOCH_TIMESTAMP});

with ths:

 

    var randomUserId;
    var userId = ""; /* Replace the empty string "" with logged-in customer id as a string if customer is logged-in*/
    if (userId === "") { /* If no userId is supplied, we manage a randomlly generated user id, which is persisted in localStorage if it is available*/
        randomUserId = "Anon" + ((Math.random() + 1) * Math.E / Math.PI).toString(36).slice(2)
        try {
            userId = localStorage.irruid || randomUserId;
            localStorage.irruid = userId;
        } catch (e) {
            userId = document.cookie.replace(/(?:(?:^|.*;\s*)irruid\s*\=\s*([^;]*).*$)|^.*$/, "$1") || randomUserId;
            document.cookie = "irruid=" + userId+"; expires=Fri, 31 Dec 9999 23:59:59 GMT";
        }
    }
    /* Now set the user_id field */
    iridize("api.fields.set", {
        user_id: userId
    });
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.