Unlock
Search…
Collecting Metadata
Learn how to configure the checkout process in order to collect members information.
In some cases, it may be valuable to collect information from purchasers before they purchase a key. For example, you may want to know the email address of all key holders so that you can send updates to them. In that case, you will want to work with user-specific metadata.
Warning: if the user already has an active membership, they will not be prompted to complete the metadata form!
To achieve this, add a property called metadataInputs to your configuration object:
1
{
2
...
3
metadataInputs: [ /* input fields */ ],
4
...
5
}
Copied!
The members of this array should have the following shape:
1
{
2
name: string,
3
type: 'text' | 'date' | 'color' | 'email' | 'url',
4
required: boolean,
5
defaultValue?: 'string',
6
public?: true,
7
}
Copied!
All fields are required except for public, which defaults to false and defaultValue. Metadata is considered protected by default, so the only people who can view it are the lock owner and the user associated with the metadata. If any metadata should be visible to everyone, mark the public field as true.
If any input has required: true, it will render on the form with a red asterisk next to it and the metadata form will not submit until it is filled appropriately.
Name fields should be unique; if they are not then there may be collisions when storing the data.
The type field maps to a certain subset of HTML <input> types, which influences how the form renders (see image).
In this example, first and last names are required and all other fields are optional.
After the user fills out the form and clicks the Continue button, they will be prompted to sign a message so the data can be verified as coming from then. After they sign, the key purchase will initiate.
Note: you can customize the callToAction value for the metadata form by adding a metadata value to this callToAction object. In some cases, it may be valuable to collect information from purchasers before they purchase a key. For example, you may want to know the email address of all key holders so that you can send updates to them. In that case, you will want to work with user-specific metadata.
To achieve this, add a property called metadataInputs to your configuration object:
1
{
2
...
3
metadataInputs: [ /* input fields */ ],
4
...
5
}
Copied!
The members of this array should have the following shape:
1
{
2
name: string,
3
type: 'text' | 'date' | 'color' | 'email' | 'url',
4
required: boolean,
5
defaultValue?: 'string',
6
public?: true,
7
}
Copied!
All fields are required except for public, which defaults to false and defaultValue. Metadata is considered protected by default, so the only people who can view it are the lock owner and the user associated with the metadata. If any metadata should be visible to everyone, mark the public field as true.
If any input has required: true, it will render on the form with a red asterisk next to it and the metadata form will not submit until it is filled appropriately.
Name fields should be unique; if they are not then there may be collisions when storing the data.
The type field maps to a certain subset of HTML <input> types, which influences how the form renders (see image).
In this example, first and last names are required and all other fields are optional.
After the user fills out the form and clicks the Continue button, they will be prompted to sign a message so the data can be verified as coming from then. After they sign, the key purchase will initiate.
Note: you can customize the callToAction value for the metadata form by adding a metadata value to this callToAction object.
Last modified 2mo ago
Copy link