Skip to main content
Version: 24.05

Star Rating - Create Widget

Endpoint​

/i/feedback/widgets/create

Overview​

Creates a new star-rating widget for an app.

Authentication​

Pass api_key or auth_token as a query parameter, or send countly-token as a header. See Authentication.

Permissions​

Requires star_rating Create permission.

Request Parameters​

ParameterTypeRequiredDescription
api_keyStringConditionalRequired if auth_token is not provided.
auth_tokenStringConditionalRequired if api_key is not provided.
app_idStringYesApp ID the widget belongs to.
statusBoolean/StringYesWhether the widget is active.
internalNameStringNoInternal widget name.
popup_header_textStringNoHeader text of the feedback popup.
popup_comment_calloutStringNoText of the comment field callout.
popup_email_calloutStringNoText of the contact-by-email callout.
popup_button_calloutStringNoText of the submit button.
popup_thanks_messageStringNoMessage shown after submission.
finalTextStringNoFinal text of the popup.
trigger_positionStringNoPosition of the trigger button, for example mleft, mright, bleft or bright.
trigger_sizeStringNoSize of the trigger button.
trigger_bg_colorStringNoBackground color of the trigger button.
trigger_font_colorStringNoFont color of the trigger button.
trigger_button_textStringNoText of the trigger button.
hide_stickerBoolean/StringNoWhether the trigger button is hidden by default.
contact_enableBooleanNoWhether the contact-by-email field is shown.
comment_enableBooleanNoWhether the comment field is shown.
rating_symbolStringNoSymbol used for ratings.
ratings_textsArray/StringNoJSON array of rating labels. When missing or not valid JSON, five default labels are used.
consentBooleanNoWhether a consent line is shown.
linksArray/StringNoJSON array of consent links. A link whose linkValue does not start with http:// or https:// has its linkValue emptied.
target_pageStringNoTarget page mode, for example all or selected.
target_pagesArray/StringNoJSON array of page paths. When missing or not valid JSON, ["/"] is used.
targetingObject/StringNoJSON object with targeting conditions. Used to create a cohort when the Cohorts plugin is enabled.
logoStringNoFile name of a previously uploaded logo.
logoTypeStringNoLogo type.
globalLogoBooleanNoWhether the global logo is used.

The widget is always created as a rating widget, shown after page load, on desktop, phone and tablet. Any showPolicy or appearance value in the request is replaced.

Examples​

Create a widget​

/i/feedback/widgets/create?
api_key=YOUR_API_KEY&
app_id=6991c75b024cb89cdc04efd2&
status=true&
popup_header_text=How was your experience?&
target_pages=["/","/pricing"]

Response​

Success Response​

201 Created

{
"result": "Successfully created 6256d161e8faa7b449e2dd6b"
}

Response Fields​

FieldTypeDescription
resultStringSuccessfully created followed by the new widget ID.

Error Responses​

  • 400
{
"result": "Invalid params: ..."
}
  • 400 when the Cohorts plugin is enabled and the targeting cohort could not be created. The widget has already been saved.
{
"result": {
"error": "Failed to set cohort",
"widgetId": "6256d161e8faa7b449e2dd6b"
}
}
  • 500: the widget could not be saved. The result holds the database error message.

Standard authentication/authorization errors from create validation can also be returned.

Behavior​

  • Runs the widget field preprocessors, then validates the payload. app_id and status are required.
  • Stores the widget in feedback_widgets with type rating, is_active set from status, a creation timestamp and zeroed counters (timesShown, ratingsCount, ratingsSum).
  • If the Cohorts plugin is enabled and targeting is given, creates a cohort from it and stores its ID on the widget as cohortID.
  • Writes a feedback_widget_created system log entry.

Impact on Other Data​

  • Adds one widget to countly.feedback_widgets.
  • May add a cohort to countly.cohorts.
Implementation details

Database Collections

CollectionUsed forData touched by this endpoint
countly.feedback_widgetsWidget storageInserts the widget and sets its cohortID.
countly.cohortsTargeting cohortsMay create a cohort (when the Cohorts plugin is enabled).
countly.systemlogsAudit trailReceives feedback_widget_created.