Can I collect data from my visitors with forms?
Can I Collect Data from Visitors Using Forms?
Yes, you can collect data from your website visitors using forms. Follow the steps below to set up your form properly.
Setting Up a Form
To set up a form, simply add the static-form
attribute to the <form>
tag.
For example:
<form static-form>...</form>
After adding the form, submit a test response, and you will be able to view the submission in the "Forms" section of your website settings. If you encounter any issues, don't hesitate to reach out for assistance.
Video Tutorial
For a quick and easy understanding of how forms work and how to integrate them, watch this short video: Form Integration Tutorial.
Storing Form Data
By default, Static.app automatically creates a new database for each page where the form is used. However, if you wish to store data in a specific database, you can add the static-form-id
attribute to the <form>
tag. Here's an example:
<form static-form static-form-id="contacts">...</form>
This will ensure that the data from this form is stored in the "contacts" database.
Adding Callback Functions
You can also add custom actions to be performed after a form is successfully submitted. Use the static-form-success-callback
attribute to trigger a callback function. For example:
<form static-form static-form-success-callback="successCallback">...</form>
Here’s an example of how to implement the callback function in JavaScript:
<script> window.successCallback = function() { alert('The message was successfully sent!') }; </script>
This callback will trigger an alert message upon successful submission.