HTML5/Javascript Integration

Pick your integration type

Plain javascript integration

With the standard javascript fetch you can interact directly with the Feelback API.

Creating a feelback

You can create a feelback with a simple API call: a POST request via fetch.

Example: Create feelback

const ENDPOINT = "https://api.feelback.dev/v0";

async function sendFeelback({ contentSetId, key, value }) {
    const response = await fetch(ENDPOINT + "/feelbacks/create", {
        method: "POST",
        headers: { "content-type": "application/json" },
        body: JSON.stringify({
            contentSetId,
            key,
            value
        })
    });

    // returns the feelbackId and, if enabled, a revocable token
    return await response.json();
}

Parameters

To specify the content receiving the feelback you can either set the pair contentSetId+key or the unique contentId. More guidance on the guide to how to specify the target content.

propertytypedefaultdescription
contentSetIdstringrequiredspecify the content-set container of the content receiving the feelback
keystringrequiredspecify the content key (unique inside the set)
valueVARIOUSrequiredthe value of the feelback, it depends on the feelback type of the content-set you specified
contextobjectundefinedoptional metadata (key/value) to enrich this feelback

Bring your own UI

Step 1: Load feelback library

Include the current script inside your page to load the feelback library:

<script defer src="https://www.unpkg.com/@feelback/js/dist/browser-auto.js"></script>

Step 2: Define UI markup to receive feelback

<div class="feelback-container" data-feelback-set="id-from-panel">
    <span>Do you like this page?</span>
    <button data-feelback-value="y">Yes</button>
    <button data-feelback-value="n">No</button>
</div>

Attributes you can specify in the container:

propertyvaluedefaultdescription
data-feelback-setstringrequiredspecify the content-set id of the content receiving the feelback
data-feelback-keystringpageURLspecify the content key (unique inside the set), if omitted, it will default to the current page URL

Attributes you can specify inside the container on various tag to enable specific logic:

propertyvaluedescription
data-feelback-valueanyon button elements, it sends the specified value as feelback value
data-feelback-countemptyon text elements(p, span, div, …), it displays the aggregated count value for this content