Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 13 Current »

In regards to the Feedier widget,

  • The widget supports any question types, conditions, and design as does the regular surveys when they are not loaded through a widget.

  • The widget’s script is 100% cached and served through a CDN (Cloudflare). Also, the requests to Feedier’s backend to load the survey data are cached.

  • The widget options in Feedier are designed to remove as much developer resource as possible from the process.

  • When possible, we recommend using a Tag Manager system to load the Feedier widget.

Where to find the widget’s JS code?

SourcesSurveys Share → Widget

Select the button and click to copy to select the widget code.

Screenshot 2024-10-24 at 23.46.03-20241024-214609.png

Click the button Save and Preview to view your changes and Preview the widget.

Adding attributes to the Widget

Adding attributes is essential to making the feedback collected through the widget actionable from the Feedier Dashboard. It gives depth to the insights and helps detect trends or issues faster.

When adding the widget, very common attributes could be:

  • browser

  • user_id

  • geolocation

  • locale

  • user_role

  • version

  • screen_size

  • page_url

  • etc.

Feedier never automatically imports any user data, or data from the page where it is loaded.

Method 1: adding attribute through the widget code URL

Attributes can be added by simply forwarding them in the URL of the widget code as GET parameters.

Here is an example to attach 3 attributes: user role, user id, signed-up date

<script id="feedier-widget-script" 
src="{endpoint}/js/widgets/v2/widgets.js?form-id={form}&
public-key={public_key}&
no_header=true&

user_id=1234&user_role=Premium&signed_up_date=10.02.24" 

async></script>

Feedier will automatically create the attribute when the first value is recorded, it does not require to be created beforehand.

Method 2: adding attributes through the JavaScript SDK

The widget can also be initialized through JavaScript and attributes can be passed in the configuration. This is very useful if the attributes data are coming after the content is loaded but through other components.

FeedierWidget.init({
    form_id: {form_id},
    attributes: {
        user_id: 'marketing',
        user_role: 'Premium',
        signed_up_date: '10.02.24'
    },
    forced: true
});

JavaScript SDK

The object loaded when the script is set is: FeedierWidget

The methods

.toggle();

FeedierWidget.toggle();

This method opens or closes the feedback widget’s content depending on the current status. It either shows the form or closes it.

For this option to work, the display delay must be set to 0.

.init(options);

FeedierWidget.init({
    form_id: 123,
    attributes: {
        browser: navigator.userAgent, // Attach the client's browser
        screen_width: window.innerWidth, // Attach the client's browser width 
        page: window.location, // Attach the client's URL
    },
    forced: true
});

This method initializes the widget based on the options object.

Option name

Type

Description

form_id

int

Feedier survey ID. It can be found in the API or on survey-> options → form management

attributes

object

Attributes to be attached to the feedback on Feedier. Attributes are contextual data coming from the client side.  

forced

boolean

If set to true, the widget will be displayed even if the user has already replied to the survey.

Listening to events

Widget event

The SDK will trigger events when the widget is built:

document.addEventListener('FeedierWidget.built', (e) => {
      // Here for example we open the widget on init
      FeedierWidget.toggle();
});

Survey events

The iframe loaded from the SDK will trigger events during the survey completion.

Whenever a question is answered,

 window.addEventListener('message', function(event) {
     if (event.data.eventName === 'question_answered') { 
        console.log(event.data);
     };
});

The event.data, is an object with the following structure:

{
    question_id: INT,
    question_option_id: ?INT,
    question_type: "nps", // "text", "choices", "rating", etc.
    question_name: STRING,
    value: STRING,
}

Whenever the survey is completed,

 window.addEventListener('message', function(event) {
     if (event.data.eventName === 'feedback_completed') { 
         // Do stuff
     };
});

The respondent might never complete the survey. Therefore this event might never be triggered.

Testing the Feedier widget

Feedier will store a timestamp in the browser’s local storage when the user completes a widget linked to the survey ID.

To test the widget without having to wait for the expiration of the timestamp stored in the local storage (defined in the widget setting in Feedier), two options are available:

  1. Option 1: Pass a preview=true parameter to stop this behavior.

  2. Option 2: In the console, wipe out the Storage → Local Storage → Feedier.widget

Use Case 1: Display the Feedier widget on a custom button click through JavaScript

SourcesSurveys Share → Widget → Visibility

In the settings,

  • Toggle off the Show on Init option

  • Add in the Custom JavaScript Loaded option: FeedierWidget.toggle()

Screenshot 2024-10-25 at 00.16.19-20241024-221626.png
  • An example of trigger:

<a href="#" id="feedback-start" class="btn btn-primary">
      Feedback
</a>
  • JS example to trigger the button with jQuery: 

<script id="feedier-widget-script" src="https://feedier.com/js/widgets/v2/widgets.min.js?form-id=770&public-key={PUBLIC_KEY}&no_header=true" type="text/javascript" async></script>

<script type="text/javascript">
        $(document).ready(function() {
              $('#feedback-start').on('click', function () {
                     FeedierWidget.init({ form_id: 770, forced: true });
              });
       });
</script>

This can be adapted with any frontend framework: React, Vue, etc.

Example: Close the widget after feedback is completed

 window.addEventListener('message', function(event) {
     if (event.data.eventName === 'feedback_completed') { $('.feedier-widget').hide() };
});

Use-Case 2: Changing the Widget style using CSS

All CSS customizations can be managed within Feedier. However, on the widget side, it might be recommended to add these customizations directly through the site’s stylesheet.

Also, there are two types of CSS changes in the Feedier widget: 

Type 1: CSS Inside the form

The styling of the widget’s content, the form is loaded through the iframe and can be controlled here:

Survey → Branding → Custom CSS

Type 2: CSS on the widget 

Survey → Share→ Widget → Design

CSS can be added to your application OR under the Design section of the widget page.

CSS classes can be explored through the inspector, the most notable ones are: 

CSS class

Description

.feedier-widget__caller

Widget feedback button

.feedier-widget__popup

Widget iframe wrapper 

Example of adding CSS to the widget

The following example will set the widget button color to red, change its font, and remove the border across the survey:

.feedier-widget__caller {
       background: #ce0707;
       color: #FFF;
       border: 0;
       font-family: Arial;
}

.feedier-widget__popup {
     padding: 0;
}

Use-Case 3: Showing the widget at specific events using Google Tag Manager

There are several advantages of using a Tag manager, including No developer time needed, proactive feedback using triggered events, and attaching attributes easily

Create a new tag in Google Tag Manager

Tag Manager → Add a new tag → Tag configuration → Paste Feedier widget code

Make sure to publish a new version of GTM when you make changes in your configuration (eg. you change the triggering method).

Then, add an explicit Tag name like “Feedback Widget Feedier” and click the Tag Configuration icon:

Using the Custom HTML under tag configuration, you can attach attributes via GTM. GTM will automatically replace the variables defined using their data layer. Eg. role={{user.role}}&plan={{user.plan}} becomes role=director&plan=enterprise

Trigger GTM based on an event

In the Tag Configuration Settings, click “Triggering”. → Then click the “+” icon to configure when to trigger the widget.

Some examples of times you might like to trigger the widget:

  • Ask for feedback after signing up

  • Ask for feedback after 5th visit

  • Ask for feedback before leaving the app

  • Ask for feedback after achieving a product goal (ordering, booking, creating, updating…)

  • Ask for feedback after a user hasn’t followed an expected flow.

Make sure that jQuery is loaded on the page. It's a common error. If your widget isn't loading, and you have no idea why, you can easily determine if jQuery is the culprit. Open the console (right-click on the page > "Inspect the page"). You will see the error that jQuery isn't loaded. 

  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.