Saving Contacts
Save new contacts in Cliengo Data Base
If you are implementing your own wesite, you can easily save data user's leave in your Forms by using our JavaScript API.
Leadaki.saveContact({
first_name : 'Morgan',
last_name : 'Freeman',
full_name : 'Morgan Freeman',
phone : '+541133261336',
mobile : '+5491140546578',
email : '[email protected]',
message : 'Hi, i want to buy a car \n Please call me.',
address : '',
tags : '', // coma separated tags
tracking : { // override automatic tracking.
utm_source: '',
utm_medium : '',
utm_campaign: '',
utm_content : '',
gclid : '', // Google AdWords clickId
contact_method : '', // form, chat or phone.
},
custom_fields: { //Any key-value pair you want to store
some_key1 : "some_value1",
some_key2 : "some_value2",
},
success : function (data){
//handler after Contact is successfully saved.
},
error : function (data){
//handler if something went wrong when saving Contact.
}
})
All fields are Optional, but in order to save any valid Contact in Cliengo Data Base you should provide at least one combination of email, phone o mobile with data.
Below the explanation of every field:
first_name | Contact's first name. |
last_name | Contact's last name. |
full_name | Use this field en case you dont have first and lastname splited in two fields. |
phone | Contact's phone number. |
mobile | Contact's mobile phone number. |
Contact's email. | |
message | Contact's mesage. Usually your Contact's question, doubt or message. |
address | Contact's address. Free string where you can include zipcode, city, street, number, state or country. |
tags | Coma separated strings for tagging your Contact. |
tracking | Tracking information about your Contact. This fields are automatically tracked with Cliengo AutoTracking but you can override them with this option. |
custom_fields | Any key-value pair you want to store in this Contact |
success | Function handler that executes after Contact is successfully saved in Cliengo Database. |
error | Function handler if something went wrong when saving Contact in Cliengo Database. |
Duplicated Contacts:
Cliengo Data Base will automatically merge new Contacts with the same email address in your account, and will also eliminate duplicated messages when information is exactly the same.
This means that you dont have to worry about users submiting information multiple times in your webiste. Cliengo Data Base will take care of it.
Working example
<!-- This is your Website Form -->
<form action="" onsubmit="return mySubmitFunction()">
<input type="text" name="fullName" id="fullName" value="John Doe">
<input type="text" name="email" id="email" value="[email protected]">
<input type="text" name="phone" id="phone" value="+1 555-5555">
<textarea type="text" name="message" id="message">
Lorem impsum...
</textarea>
<input type="submit" value="Send Information">
</form>
<!-- This is your Script for saving Contacts -->
<script>
function mySubmitFunction() {
Leadaki.saveContact({
full_name : document.getElementById("fullName").value,
phone : document.getElementById("phone").value,
email : document.getElementById("email").value,
message : document.getElementById("message").value,
success : function() {
alert("Contact was successfully saved!");
},
error : function() {
alert("There was a problem. Try again later.");
}
})
return false;
}
</script>
<!-- Reminder: you need your Cliengo Instalation Script pasted somewhere in this page -->
Updated over 3 years ago