💡 If you want to learn more about OpenWidget's JS API, check out our official Developers' Documentation.
HTML Attributes are dedicated parameters you can add to interactive elements of your website or app, like function buttons. These attributes are designed to interact with OpenWidget, enabling you to trigger the available actions and features without writing complex code. As an example, with HTML Attributes, you can prepare a simple button that maximizes your OpenWdiget bubble and redirects your customer straight to a specific feature, like our Frequently Asked Question Template (FAQ) or other available forms.
HTML Attributes consist of two main parameters:
The main parameter: data-openwidget-action. This parameter determines the action you want to perform with OpenWidget. It has two available values: minimize and maximize.
The second optional parameter: data-openwidget-feature. This parameter is available only when the value for data-openwidget-action is set to maximize. You can include this parameter to specify which OpenWidget feature should appear after maximizing the widget. The list of available features looks as follows:
Let's see how you can use HTML Attributes to create custom interactions with OpenWidget:
- Minimize Action: To minimize OpenWidget's Home Screen, you can add the following attribute to your website's interactive element:
- Maximize Action without Specifying Feature: To maximize OpenWidget without specifying which feature should be opened, use the following attribute:
- Maximize Action with Specified Feature: To maximize OpenWidget and open a specific feature, use both data-openwidget-action and data-openwidget-feature attributes combined and specify which feature you would like to open:
After adding our HTML Attributes, your custom button's code should look like this:
<button type="button" data-openwidget-action="maximize" data-openwidget-feature="form-bugreport" > Report a Bug </button>
Now, let's walk through a step-by-step tutorial on adding a custom button to a WordPress website that maximizes OpenWidget with the form-bugreport feature.
- Open Your WordPress Dashboard and Edit Your Content
- Edit your post or page where you want to add the custom button or edit the existing page on your WordPress website.
- Open the Block inserter by clicking on the + button available at the top left section of your WordPress.
- From the Design section, click on Buttons.
- Modify its looks, copy and other aspects to your liking.
- Once your button is ready, open the Options menu available while editing your button and click on Edit as HTML.
- In the div class structure, add the OpenWidget attributes that you'd like to use, for example:
Now your button's code should look like on the following example:
<div class="wp-block-button" data-openwidget-action="maximize" data-openwidget-feature="form-contact" > <a class="wp-block-button__link wp-element-button">Contact us!</a> </div>
Publish or Update Your Content
- Now that your button is ready, you can preview your post/page to see it in action. If everything looks good, publish your freshly updated content and that's it! Your customers can now use a new way to interact with OpenWidget.
Congratulations! You've successfully learned how to use OpenWidget HTML Attributes to create custom interactions with the widget. By adding these attributes to your website's elements, you can easily control OpenWidget's behavior and enhance user engagement.