Attach Custom Data
Enrich each feedback entry by attaching additional data, such as user roles or account types. This adds context to feedback, making it easier to analyze. Looking to identify users? See User Identification.
Before you startThe Userback widget must be installed on your website. See the Widget Installation Guide if you haven't done this yet.
Custom data methods
Method 1. setData(data: object)
setData(data: object)Dynamic and session-specific data. Useful when initializing the JavaScript SDK via init(). Can be called multiple times, overwriting previous data.
Userback.setData({
AB_test_variant: 'B',
time_on_page: '2m 15s'
});Method 2. custom_data: object
custom_data: objectStatic data. Useful when SDK hasn't been initialized or when using Basic Snippet installation.
Userback.custom_data = {
page_name: 'Checkout',
user_status: 'Active'
};Basic use cases
| Use case | Example |
|---|---|
| Track user journey | Userback.setData({ page_name: 'Checkout' }); |
| Application versioning | Userback.custom_data = { app_version: '1.2.5' }; |
| Feedback context | Userback.setData({ activity_type: 'Reading', content_type: 'Article' }); |
| A/B testing variants | Userback.setData({ AB_test_variant: 'B' }); |
Advanced use case
Page scroll tracking
Capture the user's scroll position to understand where they were on the page when giving feedback. This is especially useful for long-form content.
You can dynamically update the scroll_position based on user scroll events.
window.addEventListener('scroll', function() {
let scrollPosition = window.scrollY || document.documentElement.scrollTop;
Userback.setData({
scroll_position: `${scrollPosition}px`
});
});Restrictions
- Key names should not contain special characters.
- Values must be JSON strings, numbers, or booleans.
Accessing custom data
Feedback dashboard sidebar
Custom data attached to feedback can be accessed from the right-hand panel of the feedback dashboard.
Need help? Visit the Help Center or use the chat bubble on this page to contact our support team.