# Add custom data in your form response

You can include custom data with user responses. The custom data may come from
URL or it may be generated based on any action on the page and then passed down
using JavaScript.



If you are looking to add the URL parameter data inside the conversation, please
refer this article
[https://collect.chat/help/article/1122-add-data-from-url-parameters-inside-a-conversation].


ADD URL PARAMETERS IN SETTINGS

Let's say your URL is

https://yourwebsite.com/?name=amy&userid=AOJ843

Here you have two pieces of information, name and userid that need to be sent
along with the form response. Both URL parameters are known to you. In this
case, you can pass these URL parameters to the form using custom fields.



Go to Settings of your form, then click on Data Collection. Click on add custom
field button and provide the parameters as custom fields. Here you will be
adding two keys, name and userid.



Once they are defined in the settings, the form will be able to pick it up and
send it along with the rest of the conversation that user had with the form. You
will be able to see these data points in the response section as well as in the
email notifications [/article/1019-email-notifications].



Note



Passing URL parameters to the form works only when the form is used
in Widget mode
[https://collect.chat/help/article/1004-how-to-add-chatbot-widget-to-website] and
when used in Link mode
[https://collect.chat/help/article/1006-share-chatbot-as-a-landing-page]. It
will not work in Embed mode. For embed mode we suggest the following method
given below.


ADDING DATA USING JAVASCRIPT

You can pass the custom data like the user's email which is available in your
web app using our Javascript API
[https://developers.collect.chat/]'s collectchat.set
[https://developers.collect.chat/#/custom?id=collectchatsetkey-value] method.
Here also, you have to set these keys in Settings > Response of your Bot, like
above. An example code:

<script>
var collectchat = window.collectchat || {};
collectchat.ready = function() {
    collectchat.set('email', 'email@user.com');
    collectchat.set('country_code', 'US');
}
</script>




Note



This code will work on both Widget and Embed mode. Please see How to enable
developer options when chatbot is in Embed mode?
[https://collect.chat/help/article/1139-how-to-enable-developer-options-when-the-chatbot-type-is-embed] for
more information.