Developer: How to pre-fill the prepopulation form

Signup for a free 18-days trial today

Developer: How to pre-fill the prepopulation form

In Knowledge base >

It is easy to prefill the prepopulation form. You can prefill with the logged-in users information, or anything that is suitable.

In your javascript tag, before </script>, add one or more of the variables cs_name (optional), cs_email (optional) and cs_question (optional). See the example below:

<script type="text/javascript">
	(function(d,c){
		var scrs=d.getElementsByTagName("script");var scr=scrs[scrs.length-1];var e=d.createElement("script");e.async=true;e.src=("https:"==document.location.protocol?"https://":"http://")+"chat.csupporthq.com/external/chat-float-inline.js?"+scrs.length;
		if(typeof c=="function")if(e.addEventListener)e.addEventListener("load",c,false);else if(e.readyState)e.onreadystatechange=function(){if(this.readyState=="loaded")c();};
		scr.parentNode.insertBefore(e,scr);
	})(document,null);
	// Below is the pre-filled information
	var cs_name="My Name";var cs_email="contact@csupporthq.com";var cs_question="My question?";
</script>

You can use server side coding to make the information dynamic. Remember to escape for quotes so you don’t break the tag.

If you wish the user to auto start a session with pre-filled information, you just add the tag cs_autostart=true;. See the example below:

<script type="text/javascript">
	(function(d,c){
		var scrs=d.getElementsByTagName("script");var scr=scrs[scrs.length-1];var e=d.createElement("script");e.async=true;e.src=("https:"==document.location.protocol?"https://":"http://")+"chat.csupporthq.com/external/chat-float-inline.js?"+scrs.length;
		if(typeof c=="function")if(e.addEventListener)e.addEventListener("load",c,false);else if(e.readyState)e.onreadystatechange=function(){if(this.readyState=="loaded")c();};
		scr.parentNode.insertBefore(e,scr);
	})(document,null);
	// Pre-filled information IS NEEDED for auto start to work
	var cs_name="My Name";var cs_email="contact@csupporthq.com";var cs_question="My question?";
	var cs_autostart=true;
</script>

If the information is filled out correctly the user start right away. In this case you will need to fill out both cs_name and cs_email correctly.

Happy coding.