Customerlabs CDP Documentation
This article contains all the JavaScript Helper Functions (JS helper functions) that can be used to track all the events on your website.
Shiprocket Create User:
<script> var userTraits = {}; var userkeys = ["first_name", "last_name", "email", "phone_num", "city", "state", "country", "pincode"]; userkeys.forEach(function(key){ var trait = window.google_tag_manager["GTM-ABCDEFGH"].dataLayer.get(key); if(trait || trait === ""){ userTraits[key] = trait; } }); var email = userTraits["email"]; var phone = userTraits["phone_num"]; var userProperties = { "customProperties": { "user_traits": { "t": "Object", "v": { "firstname": { "t": "string", "v": userTraits["first_name"] }, "lastname": { "t": "string", "v": userTraits["last_name"] }, "email": { "t": "string", "v": email }, "phone": { "t": "string", "v": phone }, "city": { "t": "string", "v": userTraits["city"] }, "state": { "t": "string", "v": userTraits["state"], }, "country": { "t": "string", "v": userTraits["country"], }, "zip": { "t": "string", "v": userTraits["pincode"], }, } } }, }; if(email && email != null && email != ""){ userProperties["customProperties"]["identify_by_email"] ={ "t":"string", "v": email, "ib": true } if(phone && phone != null && phone != ""){ userProperties["customProperties"]["external_ids"] = { "t": "Object", "v": { "identify_by_phone": { "t":"string", "v": phone } } } } }else if(phone && phone != null && phone != ""){ userProperties["customProperties"]["identify_by_phone"] = { "t":"string", "v": phone, "ib": true } } if (phone || email) { _cl.identify(userProperties); } </script>