Documentation

Adding metadata to questions

It's widespread to have a survey where we want to ask similar questions about various tags. We might be asking about different TV shows, product features, or political candidates, but the pattern is generally the same:

  • Cycle over a set of tags that we want to ask questions about
  • Ask the same questions about each tag

For example, we could ask about attitudes toward various social media platforms. In this case, our tags could include Facebook, Instagram, Twitter, and TikTok. The survey questions might be something like:

How often do you use {platform}?
How satisfied are you with your experience on {platform}?
How likely will you recommend {platform} to a friend?
What do you like most about {platform}?
What do you dislike about {platform}?

The same questions are repeated for each platform. This approach allows us to gather consistent data across different tags, making it easier to compare and analyze results.

With MX8 Labs, we make this process more efficient in both survey programming and reporting by passing each tag separately to the question, as shown below:

from survey import Survey

s = Survey(**globals())

platforms = ["Facebook", "Instagram", "Twitter", "TikTok"]

for platform in platforms:
    with s.tag(platform=platform):
        s.select_question("How often do you use {platform}?",
                          options=["Never", "Rarely", "Sometimes", "Often", "Always"])

        s.rating_question("How satisfied are you with your experience on {platform}?",
                          number_of_points=5,
                          style="slider",
                          labels={
                              1: "Very Dissatisfied",
                              3: "Neutral",
                              5: "Very Satisfied"
                          })

        s.rating_question("How likely will you recommend {platform} to a friend?",
                          number_of_points=5,
                          style="slider",
                          labels={
                              1: "Very Unlikely",
                              3: "Neutral",
                              5: "Very Likely"
                          })

        s.text_question("What do you like most about {platform}?")

        s.text_question("What do you dislike about {platform}?")

s.complete()

In the above example, you can see that we're specifying a different platform for each question. We do that by wrapping the questions in a with s.tag(platform=platform): block, which attaches the tag to every question created inside it. To tag a single question instead, pass the tags directly to that question with tags=s.tag(platform=platform). Either way, the tag will be added to the question and be available for:

a) Reporting - you can include the tag as a row or a column on any report including that question.

b) Question text - you can include the tag in the question text by incorporating it in the question text, surrounded by the curly brackets {}.

c) Survey logic - tags travel with the returned response value, where you can read them as attributes (for example, answer.platform) or through the response's topics dictionary.

This approach can be extended by adding conditional logic in more complex surveys. For instance, if a respondent indicates that they never use a particular platform, the survey can skip the remaining questions for that platform, saving the respondent time and keeping the data clean.

This method not only saves time during the survey design process but also helps in the analysis phase, as the responses can be directly compared across tags, revealing trends, preferences, and areas for improvement.

Reporting options

Here you can see an example in report settings, where two tags are included in the questions in the report, and you can configure them as either row, column, or to ignore them:

Adding Metadata To Questions

Special cases

Some keywords are not allowed to be used as tags, and the platform rejects them with a validation error. These are names reserved for question parameters, response properties, and export columns:

  • Question parameters and response properties: index, is_valid, error_message, recodes, text, get_custom_error, default, unique_id, specified_option, topics
  • Common misspellings of question parameters: exclusive_option, fixed_option
  • Export column headings: respondent_id, status, question, reporting_id, line_number, type, response, raw_response, responded, timestamp, reportable, weight

The keyword "ix" is allowed as a parameter but is unavailable for inclusion in reporting.