The exact method you'll use to extract and store a user's cookie ID will vary slightly depending on when and how you are able to identify your users. Generally, cookie extraction is best done at a point where the user is explicitly confirming their email address - during a signup or login process for example. 

The LiftIgniter cookie is not dependent on a user's authentication state, so our cookie value will not change (unless they clear their cookies completely). If you already have your user's tracked and associated with an email in another system, you could technically read our cookie value at any time in order to associate our userId with that existing information. You may also choose to override our cookie with your own value to keep IDs consistent between systems. 

Please note that LiftIgniter does not accept personally identifying information about users. You may not use the email address of the user as their cookie value.

If you'd like to discuss your implementation please do reach out to Support to schedule a call or discuss over email. We'll be happy to help provide a solution for you. I f you are interested in finding out more about our user tracking, check out our article on user cookies and the data we collect.

Option 1: Extracting the UserId from the LiftIgniter Cookie

When your user submits a form or logs in with their email address, you can use Javascript to extract the cookie and add the value to a hidden input field. You'll need to make sure this value gets to your marketing automation or email service platform so that it can be used to personalize the URLs that will generate the recommendations.

The name of the cookie that you will need to extract is "_ig". Below is a sample script with one method of extracting the cookie and inputting the value into a specified form field.

    $.cookie(“cookie name",'_ig'); 

if ($.cookie(“cookie name")) {                
    var cookieval = $.cookie(“cookie name");            
   var inputs = document.getElementById(“hidden-field");                                
    inputs.value =cookieval;

Option 2: Overwriting the UserId Value in the LiftIgniter Cookie

This method has one significant downside over extracting and storing the userId assigned by LiftIgniter: overwriting the cookie will essentially create a "new" user in the eyes of our models. All previous behavior for the old userId will still exist, but will not be tied to the new userId.

Setting the userID can be done in a Javascript integration by using the $p("setUserId") function that is built into our SDK. Run the function after $p("init") and before $("send", "pageview") in our beacon script. This will change the randomly generated UUID on LiftIgniter to a user identifier that you have specified.

// ... Beacon
$p("init", "JS_KEY");
$p("setUserId", "USER_ID"); // USER_ID should be a string.
$p("send", "pageview");