After placing the survey on the website, we can provide additional attributes of the user visiting our website. The attributes are the data which allow you to provide additional information along with the completion of the first question.

Example: mail attribute with a value of user@startquestion.com, the city attribute with the value Warsaw [Warszawa]

Running the code

The following code snippets can be run as follows:

  • by attaching them to the page using the GTM (Google Tag Manager) or other tag managers

  • by pasting the code in the browser console

  • by attaching it to the source code of the selected website

The forwarding of the attributes has its own priorities. More information in each of the examples.

Forwarding to all widgets

Startquestion.call ({
type: "setAttributes",
attributes: {
mail: "user@startquestion.com",
city: "Warsaw"
}
});

The code will pass the mail and city attributes to all widgets which have been placed on the page. We can name them the "general attributes".


If we previously ran "forwarding to many or one widget" then the attributes will not be overwritten.


Forwarding the attributes to many surveys

Startquestion.call ({
type: "setAttributes",
attributes: {
mail: "it@startquestion.com",
city: "Warsaw"},
widgetId: [
12345, 234564,
'12345abc', '3456def', '678xyz'
]
});

Line 8: ['12345abc', '3456def', '678xyz'] will transfer the attributes to the 3 selected surveys which are displayed on our website.

NOTE! The widgetId can be forwarded as a string and as number.
Examples in the code above.


If you have previously run the "Forward to all widgets", then running the "Forward to multiple widgets" will overwrite the previously forwarded "general attributes"


Forwarding to one survey

Startquestion.call ({
type: "setAttributes",
attributes: {
mail: "it@startquestion.com",
city: "Warsaw"},
widgetId: ['12345abc']
});
// or widgetId: [12345]
// <- as a number if the ID does not contain letters

you can also do it like this:

Startquestion.call ({ 
type: "setAttributes",
attributes: {
mail: "it@startquestion.com",
city: "Warsaw"
},
widgetId: '12345abc'
});
// or widgetId: 12345 (as a number (without ''))
// <---- difference: no square brackets


It is worth to pay attention to the 7th line. Here we're telling the script to forward the attributes only to 1 survey with an id of 12345abc.


If we have previously run the "Forward to all widgets", then running the "Forward to one widget" will overwrite the previously forwarded "general attributes"


Things worth remembering

  • If we put the code to forward the attributes on our website, it should be pasted under the code which installs a survey (snippet)

  • You can run the attribute forwarding script multiple times and thus update them
    Example: The user enters the page and we set the mail attribute in the survey on "" (empty). When the user subscribes to the newsletter then we update the mail attribute by the value provided in the newsletter subscription field

  • The limitation on the number of attributes: max 15. You can send 30, but the first 15 will be saved in the database.

  • Attributes cannot be removed. If it is necessary, please contact us.

  • Attributes are saved only on the transition from the first page to the second one - in other words, after completing the first page. If, while filling in, for example, the user will move from page 3 to page 4, the attributes or their values will change, which means that they will be omitted.

Displaying a survey based on attributes

We can define in the widget display rules ("Collect" tab → Who should see the survey → Visitors meetings rules...) that the widget should be displayed only to users who meet certain criteria, for example, only to those who are from the city of Warsaw, for example,

Did this answer your question?