Help Desk Help Desk   Live Chat Live Chat   Phone +1 (917) 409-7605 M-F 9am-6pm EST
Home
Features
Screenshots
Free Trial
Pricing
Client Login
Help Desk
Search:
Help Desk » APIs and Integrations » Pre-populate visitor name and email chat request field
Pre-populate visitor name and email chat request field

This documentation is a continuation of Add custom fields on the chat request window documentation.  Custom fields are provided at the Setup Admin area and are displayed on the chat request window, while custom variables are injections of custom variables via JavaScript or created (steps detailed in this documentation).  Custom variables are not visible to the visitor unless the variable name matches any of the custom field names.

 

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: Do not include double quotes (") or single quotes (') in the custom variable name or value.

 

<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 ;

// populates the PHP Live! "Name" field on the chat request window

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

// populates the PHP Live! "Email" field on the chat request window

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

 

// populate your custom field Login

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

// populate your custom field ID

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

</script>

 

Auto-fill the Custom Field Input: If the JavaScript custom variable name matches any of the pre-defined custom fields (Setup Admin > Departments > Chat Request), the value will automatically populate for that field and the field will not be editable on the chat request form.  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).

 

Create Custom Variable URL query string to send to the chat request window: To create a custom variable URL query string, please use the following format:

 

-_- is the custom variable name value separator (name-_-value) 

-cus- is the custom variable pair separator (name-_-value-cus-name2-_-value2)

 

With the above format, custom variable URL query string can be created like the example:

phplive.php?custom=name-_-value-cus-name2-_-value2-cus-name3-_-value3

 

* If the value contains special character, encode the value string with PHP function urlencode() or JavaScript function encodeURIComponent()

 

To send the name and email for prepopulating the name and email fields on the chat request window, use the js_name and js_email variables. Also, the js_name and js_email will need to be Base64 encoded.
Example: phplive.php?js_name=<?php echo base64_encode( "Kyle" ) ?>&js_email=<?php echo base64_encode( "Kyle@somewhere.com" ) ?>

 

Was this helpful?
could be more helpful? let us know
22 people found this helpful