When creating Intuiface experiences, it is possible to capture user data at runtime and save it to a persistent data store.
For example, perhaps you would like someone interacting with our experience to be able to enter their first name, last name, e-mail address and additional comments. When the user touches a "Submit" button, this information is stored in a persistent way that can then be accessed for future reference.
Create the form
Imagine a simple Contact Form with the following elements and associated requirements:
- Name: mandatory input field, needs to be text with a minimal number of characters
- Company: optional input field, no format requirement
- Email: mandatory input field, needs to be text with an x@y format
- Message: mandatory input field, needs to be text with a minimal number of characters
- Submit: button to save the form data. Disabled if any of the above required fields aren't completed, enabled once everything is OK
Now we need to meet our requirements for each input.
The simplest way to make a field mandatory is to set a Text Input Asset's "Min Characters" property to a value greater than zero. We've set it to 3 for Name and 10 for Message.
Format requirements (e.g. email)
For the email Text Input Asset, we need to ensure a valid email format. To do that, we'll use a regular expression. In the Properties panel of the Text Input Asset, in the "Behavior" section, check the "Use custom regular expression" box and insert the appropriate expression.
NOTE: There are plenty of sites providing regular expression patterns for validating email addresses, phone numbers and more. For example, here is one site with prebuilt regex patterns.
Enable the Submit Button
In order to enable the Submit button, we are going to use the following technique:
- For each of the three fields with a requirement (Name, Email and Message) we are going to add Toggle Button Asset to the scene.
- The status (disabled/enabled) of the Submit button is bound to the "Checked" property of a fourth Toggle Button.
- When a requirement is met on one of the 3 Text Input assets, we check the associated Toggle Button. When the condition is not met, we uncheck the associated Toggle Button. In order to do this, we use the Input Text Asset triggers "Validates the entered text" and "Identifies invalid text"
- Every time one of the three Toggle Button is checked, we also watch the other two. When all are checked, we check the fourth Toggle Button, enabling the Submit button.
- Every time one of the three Toggle Button is unchecked, we uncheck the fourth Toggle Button, disabling the Submit button.
- To inform the user if his/her input is valid, we display text messages whose visibility is linked to the validation triggers.
- The Toggle Buttons should be placed outside the scene. They should not be visible as they are only being used to facilitate enablement of the Submit button.
Sample experience to try it out
You can download a sample here that illustrates how to build a Contact Form. This example also uses the Intuiface Data Tracking feature for data storage, as explained in the next section.
The first - and preferred - method for capturing user information at runtime is use of the data tracking feature. With data tracking you can log virtually any information about any event - user action, data input, environmental info, e-mail, etc. - that occurs in your experience. Why the preferred method? It's simple, works both on-line and off-line and scalable as it can be used with any number of displays.
In addition to information like 'item selected', data tracking also makes it possible for Intuiface to identify the habits and demographics of those who use the interactive content. This data can even be collected in an environmental context, meaning you can capture information like location and weather, potential influences on user decisions. Any information accessible on the device can be consumed by Intuiface.
Another method for capturing user information at runtime is to use a local Excel file. Have a look at the video below to discover how you can leverage the Excel Interface Asset, the Text Input Asset and the Intuiface binding mechanism to fulfill this need.
When creating an Excel Interface Asset in Composer, the Excel workbook containing the referenced spreadsheet is copied and placed into your project at the following location:
All modifications achieved through the use of the Excel IA's Add row action are applied to this local copy. If you want to retrieve the user data collected at runtime, you need to open the local copy of the Excel workbook, not the original. (The iPad is not very friendly re: browsing its file system for the retrieval of files. To get the Excel workbook off an iPad, see this article.)
Please note that if you have multiple Players deployed, collecting all local Excel files and (manually) collating them into one giant Excel file might be a very tedious, error-prone and time-consuming process. Ergo the first method above using the Intuiface Data Tracking feature.
If you would like to get your hands on this experience, download the Intuiface project from here.