Skip to main content

Functions

INIT

The init function enables you to showcase every survey from your project without requiring any additional coding.

It will automatically search for triggers and display a survey whenever it matches the user's actions.

told('init', {{SOURCE_ID}}, {{OPTIONS}});

Parameters:

SOURCE_ID: This is your source ID, which enables the SDK to search for every survey within the source designated to be displayed on your website. Example:

told('init', '64807004d103fe001313xxx')

OPTIONS.PREVIEW: You can launch your survey in preview mode. The data collected from your respondents will not be counted in your reports. Your surveys don't need to be activated for them to be displayed. Example:

told('init', '64807004d103fe001313xxx', {preview: true})

OPTIONS.HIDDENFIELDS: AEnables you to programmatically include personal data from respondents in the report. Example:

told('init', '64807004d103fe001313xxx', {hidden_fields: { name: 'toto', email: '[email protected]'}})

ADD HIDDEN FIELDS

This feature enables you to add hidden fields after initialization (init function).

It allows you to programmatically include personal data from respondents in the report. If you want to know more please refer Users page.

told('identify', {{DATA}});

Example:

told('identify', { name: 'toto', id: 'CXXCVIXIDCHX'});


SET LANGUAGE

In the edition, you have the option to set up multiple languages. By default, the script will detect the user's browser language.

If the browser's language doesn't align with the language configured in the software edition, it will resort to the default language.

To override the preset settings, you can input the key language along with its value in the hidden fields.

Example:

told('identify', {  language: 'es' });


DEBUG

This feature allows you to debug your source to determine which survey should be displayed and to identify any potential issues or misconfigurations.

SOURCE_ID should be replaced by your own source ID.

told('debug', 'SOURCE_ID');

ADD EVENT

Enables you to add events to Told, which can then be utilized to trigger surveys through the custom events configured.

told('addEvent', {event: 'test', name: 'toto'})

The function requires an object as an argument, which should include a variable named "event" for it to be utilized. Additional variables can be added as needed.

This example will trigger any survey that has a custom trigger named "test" and a variable named "name" with the value "toto".


GROUP

The group function allows you to associate users with teams or organizations. This function helps identify the account or organization your users belong to.

told('group', id, data, id)

Parameters

  • id (required): A unique identifier for the group in your database.
  • data (optional): A free-form dictionary containing additional information about the group.
  • id (optional): The id of the user you want to associate with the group. If not provided, the function will use the current user by default.

If you want to know more please refer to the Groups page.

Notes