php Live! Help Desk
Search:
» Help Desk Home » APIs and Integrations » Pre-populate visitor name and email chat request field
Pre-populate visitor name and email chat request field

To pre-populate the visitor name, email or the question field on the visitor pre-chat request form, you'll want to place a JavaScript code on your webpages.  We have opted to go with the Javascript method because the integration is straight forward with much flexibility. When the PHP Live! HTML code detects the "phplive_v" variable on the webpage, the system will carry those values to the visitor chat request window. For websites with a standard header or footer throughout all the pages, this method of integration is effortless. If the Name, Email or the Question fields are passed via the "phplive_v" variable, the fields will not be editable on the chat request form (the question will still be editable).

 

IMPORTANT: Custom variable names and custom variable values should not contain double quotes (") or single quotes (').

 

<script type="text/javascript">

var phplive_v = new Object ;

phplive_v["name"] = "The Name" ;

phplive_v["email"] = "The Email" ;

</script>

 

To pass a PHP variable to the JavaScript, simply provide the values as the PHP variable, such as:

 

phplive_v["name"] = "<?php echo $name ?>" ;

phplive_v["email"] = "<?php echo $email ?>" ;

phplive_v["vquestion"] = "This is a pre-populated question." ;

 

Custom Variables (PHP Live! v.4.2.109+) - Custom variables are not visible to the visitor but will be visible on the operator console for the operator and the variables are saved to the system.  To integrate your own custom variables to be displayed on the operator console (such as ticket #, login, customer ID, etc), add the custom variables to the phplive_v variable.  As an example:

 

<script type="text/javascript">

var phplive_v = new Object ;

phplive_v["name"] = "<?php echo $name ?>" ;

phplive_v["Login"] = "<?php echo $login ?>" ; // your own custom variable

phplive_v["CID"] = "<?php echo $customer_ID ?>" ; // your own custom variable

</script>

 

Custom fields are visible to the chat operators during a chat session and the values are also saved to the database and can be viewed at anytime (chat transcripts, leave a message, etc).  If the JavaScript custom variable name matches any of the pre-defined custom fields (Setup Admin -> Departments -> Pre-Chat), the value will automatically be populated for that field and the field will not be editable on the chat request form.

 

Was this documentation helpful?