Set Name/Email/OrderID in Crisp Automatically

This code will check if email address / order ID exists, then push user name/email/segment to Crisp automatically.

Add following code to the footer of both Desktop and Mobile templates.

<script>
var cusemail = '%%GLOBAL_CurrentCustomerEmail%%';
var cusorder = '%%GLOBAL_OrderId%%';
if(cusemail != ''){
    $crisp.push(["set", "user:email", ["%%GLOBAL_CurrentCustomerEmail%%"]]);
    $crisp.push(["set", "user:nickname", ["%%GLOBAL_CurrentCustomerFirstName%% %%GLOBAL_CurrentCustomerLastName%%"]]);
}
if(cusorder != ''){
    $crisp.push(["set", "session:data", ["Order", "%%GLOBAL_OrderId%%"]]);
}
$crisp.push(["set", "session:segments", [["moddiy"]]]);
</script>‚Äč

Leave a Reply

Your email address will not be published. Required fields are marked *