Customerlabs CDP Documentation

You are here:

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>

Was this article helpful?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
How can we improve this article?
How Can We Improve This Article?
Need help?
Table of Contents
CustomerLabs gives freedom, flexibility and wings to digital marketers.
Sign Up

Schedule a 1-1 Demo