Usabilla for Websites feedback can be supplemented with information you already acquired about your user or your website. This information can be passed on to Usabilla through Custom Variables so that it will be included in feedback items and campaign results.
Please follow these steps to include Custom Variables in your feedback items and campaign results.
1. Define the data you would like to pass on to Usabilla.
Examples of Custom Variables are user names, session IDs, A/B-testing variables from other tools, demographic data and membership statuses.
2. Include the variables with a JavaScript API call.
The following JavaScript API call can be included on every page on which you would like to include Custom Variables. Please ensure the call is installed on every page below the Usabilla code.
<script type='text/javascript'>
window.usabilla_live('data', {'email': 'usabilla@example.com',
'custom':{'Username': username, 'SessionID': session_id} } );
</script>
In this example, "email", "Username" and "SessionID" are the custom variables names that will appear in Usabilla, while the values indicate a reference to the variable.
If your website is JavaScript heavy it should be noted that the API call can be used multiple times, any call replacing the data of the previous call. So the last call’s data will be used when the feedback process is started.
Append and update Custom Variables
You can make the Custom Variables for Usabilla for Websites easily updateable by using a JavaScript Object for storing the Custom Variables. If you update the object and resend the Custom Variables using the JavaScript object you can easily keep custom variables up-to-date or even append values. Below you'll find an example of how you could achieve this:
Allowed values for Custom Variables
When you use our JavaScript API call for sending Custom Variables to usabilla you can pass on the following 2 objects:
email: The user’s email address, if your button asks the user for his email address the field will be pre-filled with the data you set here, otherwise, the email address will be sent as is.
custom: A JavaScript object containing custom data. The below data types are permitted in custom variables.
- Boolean
- Integer
- Float
- Double
- String – A string can include up to 500 characters.
- Array
- NULL
- Object
Arrays and objects can have a maximum depth of 2 and must consist of uniform values (only strings, only integers etc.).
Tip: We highly recommend that you don't use any object and or arrays. Using only uniform values allows to easily compare and export the feedback and campaign results that you gathered.
3. Success!
The Custom Variables will now be included in every feedback item and campaign result. Also, you will be able to target campaigns to users that have certain Custom Variables.