Alongside the library of default widgets in the Visual Editor, you'll be able to create your own. This requires a knowledge of Javascript and JSON.
Below, we will describe all relevant parts to this process.
Structure of a no-code widget
Overall structure
{
"friendlyName": '...',
"description": '...',
"fields": [
... list of form fields
],
js_build: function (widget) {
// generate and return code to be injected into the variation js
}
}
friendlyName
String, required.
Example
"Email capture popup 1"
This is any string that you'd like to name your widget. This name will reflect in what a user sees as a tile heading on this initial screen:
description
String, required, can be a blank string. Used as above, for the visual tile users can click on.
Example
"Our standard email capture popup"
fields
Array, required. Field spec varies from field to field, and so is best described below.
Note: the "name" key that you pass into each of your fields is the same value that will be passed into your js_build function.
Example
[
"CONTENT",
{ name: "field1", type: "text", ... },
{ name: "field2", type: "textarea", ... },
"STYLING",
{ name: "field3", type: "color", ... },
{ name: "field4", type: "color", ... },
"POSITION",
... etc
]
Common attributes
id
This is the ID for the field. Beyond allowing for minor customisations and targeting, it does not serve any wider user purpose.
βname
This is the same "key" that will be passed into the js_build function. We recommend lowercase letters without spaces, underscores are allowed.
βlabel
This is the friendly name that you'd like to appear above the input field. This is what users of the widget will see.
βnote
Notes are optional, will appear after your field, and can provide some additional guidance to your users for using that field. You can provide HTML into here, but only aesthetic elements (p, strong, span, etc.).
β
js_build
JS Function, required. Must return the string you'd like us to inject into the Variation JS.
Example
js_build: function (widget) {
var uniqueID = Date.now();
var str = `//!-##${widget.widgetType}--START##
// ${JSON.stringify(widget)}
(function(){
var settings = {
outerbgcol:'${widget.outerbgcol}', // outer background colour
containerwidth: '${widget.containerwidth}',
imglink: '${widget.imglink}', // image change
closepopupcol: '${widget.closepopupcol}', // change x colour
// ...
};
document.body.insertAdjacentHTML('beforeend', \`
<div id="popup-\${uniqueID}" class="popup">
<h2>\${settings.headingtext}</h2>
<p>\${settings.paragraph}</p>
// ...
</div>
\`);
})();
//!-##${widget.widgetType}--END##`;
return str;
}
Required markers in the string
Data provided (arguments)
This function consumes an object, in the shape of:
{
"field1_name": "field1_value",
"field2_name": "field2_value",
...
"fieldN_name": "fieldN_value",
}
You must process this data how you wish, and output it as a string that we can inject as appropriate.
Field types
Below are a list of all field types you can use when creating your no-code widget. If you would like other types, we are happy to extend our list - just ask.
Field Group / string
Field type | N/A. Just provide a string, similar to "FIELD GROUP 1" |
Description | This is used to create a collection of form fields, grouping together anything that proceeds it.
To create a subsequent form group, simply provide another string of text lower down in your fields array. |
Attributes | N/A |
Example | fields: [ |
Screenshot |
Text
Field type | "text" |
Description | Single-line text field. |
Attributes | All common attributes, like type, id, name, label and note.
Additional attributes:
|
Example | [ |
Screenshot |
|
Number
Field type | "number" |
Description | Numeric input field |
Attributes | All common attributes, like type, id, name, label and note.
Additional attributes:
|
Example | [ |
Screenshot |
Date and time
Field type | "date-and-time" |
Description | Gives you a datepicker, allowing users to build date-centric experiences like countdown timers. |
Attributes | All common attributes, like type, id, name, label and note.
No additional attributes. |
Example | { |
Screenshot |
Textarea
Field type | "textarea" |
Description | A multi-line textarea field. For single-line, see "text". |
Attributes | All common attributes, like type, id, name, label and note.
Additional attributes:
|
Example | { |
Screenshot |
Color
Field type | "color" |
Description | A colour picker. |
Attributes | All common attributes, like type, id, name, label and note.
Additional attributes:
|
Example | { |
Screenshot |
Note: We use the HTML default field, and so the appearence of this may vary between browsers and operating systems. |
Checkbox
Field type | "checkbox" |
Description | A checkbox with a label. |
Attributes | All common attributes, like type, id, name, label and note.
Additional attributes:
|
Example | { |
Screenshot |
|
Radio
Field type | "radio" |
Description | A group of connected radio fields, allowing for selection of a single value from a list of options. |
Attributes | All common attributes, like type, id, name, label and note.
Additional attributes:
|
Example | { |
Screenshot |
Range slider
Field type | "range" |
Description | A slider, with min/max and step values that the user will be able to control. |
Attributes | All common attributes, like type, id, name, label and note.
Additional attributes:
|
Example | { |
Screenshot |
On page position - 9 options
Field type | "onpageposition" |
Description | Allow the user to select a position, which you can use for any purpose. This is cuts the canvas into 9 sections, with vertically top, centre and middle, and horiztonally left, centre and right.
Values provided should consider vertical and then horizontal, e.g. bl = bottom left. |
Attributes | All common attributes, like type, id, name, label and note.
Additional attributes:
|
Example | { |
Screenshot |
On page position - top or bottom
Field type | "onpagepositiontb" |
Description | Unlike the default on page position which allows you to target all 9 sections, this is limited to top or bottom. |
Attributes | All common attributes, like type, id, name, label and note.
Additional attributes:
|
Example | { |
Screenshot |
Launch iframe
Field type | "launch-iframe" |
Description | Allows you to launch an iframe and embed another application into this one. |
Attributes | All common attributes, like type, id, name, label and note.
Additional attributes:
|
Example | { |
Screenshot |