As we all know we can get the custom detail of the users/visitors who clicks the live chat icon in the website. In salesforce the details of the users/visitors will be available for the Agent in the visitor detail page but, when you are trying to pull the reports for that data which resides in the Visitor detail page, it is not possible.
If we want those data for reporting we need to do some code change in the website page as well as we need to create some fields in the Live Agent Transcript Object.
Here is the code,
<html>
<script type='text/javascript' src='https://c.la3-c1cs-was.salesforceliveagent.com/content/g/js/36.0/deployment.js'></script>
<script type='text/javascript'>
liveagent.init('https://d.la3-c1cs-was.salesforceliveagent.com/chat', 'XXXXXXXXXXXXX', 'XXXXXXXXXXXXXXX');
liveagent.addCustomDetail("9.First Name", "Priya").saveToTranscript("First_Name__c");
liveagent.addCustomDetail("8.Last Name", "Mohanraj").saveToTranscript("Last_Name__c");
liveagent.addCustomDetail("7.Email", "priyamohanraj754@gmail.com").saveToTranscript("Email__c");
liveagent.addCustomDetail("4.Display Name", "Priya").saveToTranscript("Display_Name__c");
liveagent.addCustomDetail("3.User Name", "priya").saveToTranscript("User_Name__c");
liveagent.addCustomDetail('5.Language', 'English').saveToTranscript("Language__c");
liveagent.addCustomDetail('6.Country', 'India').saveToTranscript("Country__c");
liveagent.addCustomDetail('1.User ID', '1234').saveToTranscript("User_ID__c");
liveagent.addCustomDetail('2.Full Name', 'Priya Mohanraj').saveToTranscript("Full_Name__c");
</script>
<img id="liveagent_button_online_XXXXXXXXXXXXXXXX" style="display: none; border: 0px none; cursor: pointer" onclick="liveagent.startChat('XXXXXXXXXXXXXXX')" src="https://english.na2.force.com/liveagentbutton/resource/XXXXXXXXXXXXXXX/livechatbtnonline" />
<img id="liveagent_button_offline_XXXXXXXXXXXXXXX" style="display: none; border: 0px none; " src="https://english.na2.force.com/liveagentbutton/resource/XXXXXXXXXXXXXXXX/livechatbtnoffline" />
<script type="text/javascript">
if (!window._laq) { window._laq = []; }
window._laq.push(function(){liveagent.showWhenOnline('XXXXXXXXXXXXX', document.getElementById('liveagent_button_online_XXXXXXXXXXXXXXX'));
liveagent.showWhenOffline('XXXXXXXXXXXXXXXX', document.getElementById('liveagent_button_offline_XXXXXXXXXXXXXXX'));
});</script>
</html>
In the above code saveToTranscript is doing the magic. If we give this method along with the custom detail then, it will save the data in the Transcript object in the mentioned field. The fields which are mentioned inside of the SaveToTranscript method is a custom fields which we needs to be created in the LiveAgent Transcirpt object in salesforce.
Thanks
Happy Coding!!!
If we want those data for reporting we need to do some code change in the website page as well as we need to create some fields in the Live Agent Transcript Object.
Here is the code,
<html>
<script type='text/javascript' src='https://c.la3-c1cs-was.salesforceliveagent.com/content/g/js/36.0/deployment.js'></script>
<script type='text/javascript'>
liveagent.init('https://d.la3-c1cs-was.salesforceliveagent.com/chat', 'XXXXXXXXXXXXX', 'XXXXXXXXXXXXXXX');
liveagent.addCustomDetail("9.First Name", "Priya").saveToTranscript("First_Name__c");
liveagent.addCustomDetail("8.Last Name", "Mohanraj").saveToTranscript("Last_Name__c");
liveagent.addCustomDetail("7.Email", "priyamohanraj754@gmail.com").saveToTranscript("Email__c");
liveagent.addCustomDetail("4.Display Name", "Priya").saveToTranscript("Display_Name__c");
liveagent.addCustomDetail("3.User Name", "priya").saveToTranscript("User_Name__c");
liveagent.addCustomDetail('5.Language', 'English').saveToTranscript("Language__c");
liveagent.addCustomDetail('6.Country', 'India').saveToTranscript("Country__c");
liveagent.addCustomDetail('1.User ID', '1234').saveToTranscript("User_ID__c");
liveagent.addCustomDetail('2.Full Name', 'Priya Mohanraj').saveToTranscript("Full_Name__c");
</script>
<img id="liveagent_button_online_XXXXXXXXXXXXXXXX" style="display: none; border: 0px none; cursor: pointer" onclick="liveagent.startChat('XXXXXXXXXXXXXXX')" src="https://english.na2.force.com/liveagentbutton/resource/XXXXXXXXXXXXXXX/livechatbtnonline" />
<img id="liveagent_button_offline_XXXXXXXXXXXXXXX" style="display: none; border: 0px none; " src="https://english.na2.force.com/liveagentbutton/resource/XXXXXXXXXXXXXXXX/livechatbtnoffline" />
<script type="text/javascript">
if (!window._laq) { window._laq = []; }
window._laq.push(function(){liveagent.showWhenOnline('XXXXXXXXXXXXX', document.getElementById('liveagent_button_online_XXXXXXXXXXXXXXX'));
liveagent.showWhenOffline('XXXXXXXXXXXXXXXX', document.getElementById('liveagent_button_offline_XXXXXXXXXXXXXXX'));
});</script>
</html>
In the above code saveToTranscript is doing the magic. If we give this method along with the custom detail then, it will save the data in the Transcript object in the mentioned field. The fields which are mentioned inside of the SaveToTranscript method is a custom fields which we needs to be created in the LiveAgent Transcirpt object in salesforce.
Thanks
Happy Coding!!!
No comments:
Post a Comment