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.
GoKwik Create User Code
<script>
var obj = window.google_tag_manager[“GTM-ABCDEFG”].dataLayer.get(“eventData”) || {};
var email = obj[“email”];
var phone = obj[“phone_num”];
var userProperties = {
“customProperties”: {
“user_traits”: {
“t”: “Object”,
“v”: {
“firstname”: {
“t”: “string”,
“v”: obj[“first_name”]
},
“lastname”: {
“t”: “string”,
“v”: obj[“last_name”]
},
“email”: {
“t”: “string”,
“v”: email
},
“phone”: {
“t”: “string”,
“v”: phone
},
“city”: {
“t”: “string”,
“v”: obj[“city”]
},
“state”: {
“t”: “string”,
“v”: obj[“state”],
},
“country”: {
“t”: “string”,
“v”: obj[“country”],
},
“zip”: {
“t”: “string”,
“v”: obj[“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>