Gets the email address, full name, geolocation, and other details for this visitor. The value will be returned to the specified returnCallback.
The name, email and phone number fields are the last-known visitor information, either from your pre-chat survey, a completed offline message form, or previously updated via the API.
Geolocation information is provided to the best of our knowledge, based on the visitor's IP.
Notify operators about a certain visitor
Let's say you wanted to know when a particular customer (e.g. Olark Joe) needed your assistance:
<script>
olark('api.visitor.getDetails', function(details){
// Check for an email address
if (details.emailAddress == "[email protected]") {
olark('api.chat.sendNotificationToOperator', {
body: "Olark Joe in the house!"
});
}
});
</script>
Highlight AdWords referrals in your visitors list
Let's say you want to highlight valuable visitors in your buddy list. For example you have already paid money for a visitor to click on your AdWords campaign, or when they search for the term "buying widgets":
<script>
olark('api.visitor.getDetails', function(details){
if (details.referredByPaidAdvertisingThisVisit) {
olark('api.chat.updateVisitorNickname',{
snippet: "AdWords Referral"
})
} else if (details.searchTextForThisVisit == "buying widgets") {
olark('api.chat.updateVisitorNickname', {
snippet: "wants to buy a widget"
})
}
});
</script>
Target customers in Costa Rica
Let's say you are targeting customers in San José, the capital of Costa Rica (not San Jose in California):
<script>
olark('api.visitor.getDetails', function(details){
// Check that both conditions are true
if (details.city == "San José" && details.region != "California") {
olark('api.chat.sendNotificationToOperator', {
body: "this customer might be in San Jose, Costa Rica"
})
}
});
</script>
Target customers in Japan
Suppose you are targeting customers in Japan. You can either use the country name or the country code:
<script>
olark('api.visitor.getDetails', function(details){
if (details.country == "Japan" || details.countryCode == "JP") {
olark('api.chat.sendNotificationToOperator', {
body: "this customer might be in Japan"
});
}
});
</script>