Hidden fields
A hidden field is a field of the form that respondents do not see. The SDK fills it, and the value is saved with the response. Use hidden fields to know who answered and in what context: user ID, plan, order number, the screen the survey appeared on.
How values are matched
Section titled “How values are matched”Matching is by name. Add a hidden field to the form in Responsly for every value you want to keep, and give it the same name the app uses.
| What the app provides | Fills the hidden field named |
|---|---|
The user ID from identify | user_id |
An attribute (trait) from identify or setAttributes, for example plan | The attribute’s name: plan |
A key passed to setHiddenFields | That key, on every survey |
A key passed to showSurvey in hiddenFields | That key, on that survey only |
A value is stored only when the form has a hidden field with that name. Values without a matching field are not saved, so the same app code can serve forms that keep different sets of fields.
Values for every survey
Section titled “Values for every survey”setHiddenFields sets values that go with every survey shown from now on. Use it for context that is not a property of the user: app theme, experiment variant, current workspace.
Responsly.shared.setHiddenFields(["order_id": "A-77"])Responsly.setHiddenFields(mapOf("order_id" to "A-77"))Responsly.setHiddenFields({ order_id: 'A-77' })Responsly.setHiddenFields({'order_id': 'A-77'});ResponslySDK.SetHiddenFields(new Dictionary<string, string> { { "run_id", "42" } });- The call replaces the previous map. It does not merge. Pass everything you want to keep each time, or an empty map to clear.
- The map is saved on the device and survives restarts, until you replace it or call
reset. - Keys and values are strings. Convert numbers and booleans yourself.
Values for one survey
Section titled “Values for one survey”Pass hiddenFields to showSurvey for values that belong to that one display.
Responsly.shared.showSurvey("AbCd1234", options: ResponslyShowOptions( hiddenFields: ["order_id": "A-77"]))Responsly.showSurvey("AbCd1234", ShowOptions(hiddenFields = mapOf("order_id" to "A-77")))Responsly.showSurvey('AbCd1234', { hiddenFields: { order_id: 'A-77' } })Responsly.showSurvey('AbCd1234', hiddenFields: {'order_id': 'A-77'});ResponslySDK.ShowSurvey("AbCd1234", new ShowOptions{ HiddenFields = new Dictionary<string, string> { { "run_id", "42" } },});Per-call values are combined with the map from setHiddenFields. When both contain the same key, the per-call value is used. The stored map is not changed.
Surveys started by a trigger have no per-call values. For those, call setHiddenFields before the track or screen call that can start the survey:
Responsly.shared.setHiddenFields(["order_id": "A-77"])Responsly.shared.track("purchase_completed", properties: ["value": 49.9])Responsly.setHiddenFields(mapOf("order_id" to "A-77"))Responsly.track("purchase_completed", mapOf("value" to 49.9))Responsly.setHiddenFields({ order_id: 'A-77' })Responsly.track('purchase_completed', { value: 49.9 })Responsly.setHiddenFields({'order_id': 'A-77'});Responsly.track('purchase_completed', properties: {'value': 49.9});ResponslySDK.SetHiddenFields(new Dictionary<string, string> { { "run_id", "42" } });ResponslySDK.Track("level_completed", new Dictionary<string, object> { { "level", 12 } });Attributes or hidden fields?
Section titled “Attributes or hidden fields?”User attributes (identify, setAttributes) | Hidden fields (setHiddenFields, showSurvey) | |
|---|---|---|
| Used for targeting | yes | no |
| Saved with the response | yes, through a hidden field with the same name | yes |
| Value types | string, number, boolean, date | string |
| Update behaviour | merged | replaced |
Put facts about the user in attributes and facts about the moment in hidden fields. Do not use the same name for an attribute and a hidden-field key.
Recorded without hidden fields
Section titled “Recorded without hidden fields”Every response from the SDK also records, with no setup:
- platform (iOS or Android),
- app ID and app version,
- OS version,
- SDK version,
- locale,
- what triggered the survey: the event, the screen, app launch, or a manual
showSurveycall.
Good practice
Section titled “Good practice”- Send IDs, not personal data. An order ID is enough to join the response with your own records later.
- Never put secrets, tokens or passwords in hidden fields.
- Clear values that go stale.
setHiddenFieldspersists, so anorder_idset last week is still sent today unless you replace it.