In Salesforce Live Agent (Classic Chat), a pre-chat form is the page a visitor sees before starting a chat session. When a customer fills out fields on the pre-chat form — such as their name and email address — these values need to be captured and saved to the Live Agent Transcript object so that agents can see the visitor's details during and after the chat.
This article describes a workaround using custom Visualforce pages and Apex controllers to pass input values from the pre-chat form to custom fields on the Transcript object.
public class InsertPre{
public string Name{get;set;}
public string Email{get;set;}
public PageReference Save() {
PageReference pr= Page.LiveAgentPage2;
pr.setRedirect(true);
pr.getParameters().put('name',Name);
pr.getParameters().put('email',Email);
return pr;
}
}
<apex:page showHeader="false" controller="InsertPre">
<apex:form >
<apex:inputText value="{!Name}" id="name"/>
<apex:inputText value="{!Email}" id="email"/>
<apex:commandButton action="{!Save}" value="Save" id="theButton"/>
</apex:form>
</apex:page>
public class InsertPost{
public string Name{get;set;}
public string Email{get;set;}
public PageReference Save() {
PageReference pr= Page.LiveAgentPage2;
pr.setRedirect(true);
pr.getParameters().put('name',Name);
pr.getParameters().put('email',Email);
return pr;
}
public InsertPost(){
Name=ApexPages.currentPage().getParameters().get('name');
Email=ApexPages.currentPage().getParameters().get('email');
}
}
Used in VF page LiveAgentPage2 <apex:page controller="InsertPost">
<img id="liveagent_button_online_57390000000PC4r" style="display: none; border: 0px none; cursor: pointer" onclick="liveagent.startChat('57390000000PC4r')" src="https://free-12415f14c3a-124e539428a-12f461fef47.sandbox.cs5.force.com/resource/1314709845000/Zeco__ZC_AEO_Startup01" /><img id="liveagent_button_offline_57390000000PC4r" style="display: none; border: 0px none; " src="https://free-12415f14c3a-124e539428a-12f461fef47.sandbox.cs5.force.com/resource/1314709845000/Zeco__ZC_AEO_Startup04" />
<script type="text/javascript">
if (!window._laq) { window._laq = []; }
window._laq.push(function(){liveagent.showWhenOnline('57390000000PC4r', document.getElementById('liveagent_button_online_57390000000PC4r'));
liveagent.showWhenOffline('57390000000PC4r', document.getElementById('liveagent_button_offline_57390000000PC4r'));
});</script>
<script type='text/javascript' src='https://c.la9cs.salesforceliveagent.com/content/g/deployment.js'></script>
<script type='text/javascript'>
liveagent.addCustomDetail('Company', '{!Name}').saveToTranscript('NewField2__c');
liveagent.addCustomDetail('Email', '{!Email}').saveToTranscript('NewField__c');
liveagent.init('https://d.la9cs.salesforceliveagent.com/chat', '57290000000PC4m', '00DO00000007EgL');
</script>
</apex:page>
000385792

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.