When you're collecting feedback through the Userback widget, it can be useful to pre-fill the name and email fields for your users. This can be achieved using the Userback JavaScript API to set the name and email properties before initializing the widget.

First, you'll need to include the Userback widget code on your web page, as described in the Userback installation guide. This will ensure that the Userback object is available in the JavaScript scope of your page.

Then, before initializing the widget, set the name and email properties to the desired values

:

Userback.name = "John Smith"; Userback.email = "john.smith@example.com";

Finally, initialize the widget using the init method:

Userback.init("[your widget token]");

Now when the Userback feedback button is clicked, the name and email fields will be pre-filled with the values you specified.

It's also possible to pre-fill these fields when initializing the widget by passing options as the second parameter to the init method.

Userback.init("[your widget token]", { name: 'John Smith', email: 'john.smith@example.com' });

You can also attach to on_open event to set the values before the widget is opened.

Userback.on_open = function(){ Userback.setData({ name: "John Smith", email: "john.smith@example.com" }); }

It's important to note that the user can still change the pre-filled name and email fields before submitting their feedback, but providing them with pre-filled fields can save time and increase the likelihood that they'll submit their feedback.

Did this answer your question?