Skip to content

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.

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 providesFills the hidden field named
The user ID from identifyuser_id
An attribute (trait) from identify or setAttributes, for example planThe attribute’s name: plan
A key passed to setHiddenFieldsThat key, on every survey
A key passed to showSurvey in hiddenFieldsThat 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.

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"])
  • 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.

Pass hiddenFields to showSurvey for values that belong to that one display.

Responsly.shared.showSurvey("AbCd1234", options: ResponslyShowOptions(
hiddenFields: ["order_id": "A-77"]
))

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])
User attributes (identify, setAttributes)Hidden fields (setHiddenFields, showSurvey)
Used for targetingyesno
Saved with the responseyes, through a hidden field with the same nameyes
Value typesstring, number, boolean, datestring
Update behaviourmergedreplaced

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.

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 showSurvey call.
  • 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. setHiddenFields persists, so an order_id set last week is still sent today unless you replace it.