Skip to content

Instantly share code, notes, and snippets.

@fhinson
Created July 18, 2018 19:05
Show Gist options
  • Save fhinson/aaa1d58baea34afc55c04b94be205da4 to your computer and use it in GitHub Desktop.
Save fhinson/aaa1d58baea34afc55c04b94be205da4 to your computer and use it in GitHub Desktop.
Typeform Logic Jump Example
{
"title": "Logic Testing Survey",
"hidden": [
"survey_id"
],
"settings": {
"language": "en",
"is_public": true,
"show_typeform_branding": false,
"meta": {
"allow_indexing": true,
"description": "logic"
},
"redirect_after_submit_url": "https://www.elucd.com/en/survey",
"facebook_pixel": "241783599908102"
},
"welcome_screens": [
{
"ref": "welcome-ref",
"title": "Thank you for agreeing to take this brief survey. Your opinions are important.",
"properties": {
"description": "All responses are completely anonymous.",
"show_button": true,
"button_text": "Ok"
}
}
],
"fields": [
{
"ref": "safety_question",
"title": "When it comes to the threat of crime, how safe do you feel in your neighborhood?",
"type": "multiple_choice",
"properties": {
"description": "Choose one",
"randomize": false,
"allow_multiple_selection": false,
"allow_other_choice": false,
"vertical_alignment": false,
"choices": [
{
"label": "Mostly Safe",
"ref": "mostly_safe"
},
{
"label": "Somewhat Safe",
"ref": "somewhat_safe"
},
{
"label": "Somewhat Unsafe",
"ref": "somewhat_unsafe"
},
{
"label": "Not safe at all",
"ref": "not_safe_at_all"
}
]
},
"validations": {
"required": false
}
},
{
"ref": "respect_question",
"title": "The police in my neighborhood treat local residents with respect.",
"type": "multiple_choice",
"properties": {
"description": "Please indicate whether you agree or disagree",
"randomize": false,
"allow_multiple_selection": false,
"allow_other_choice": false,
"vertical_alignment": false,
"choices": [
{
"label": "Strongly Agree",
"ref": "strongly_agree"
},
{
"label": "Somewhat Agree",
"ref": "somewhat_agree"
},
{
"label": "Somewhat Disagree",
"ref": "somewhat_disagree"
},
{
"label": "Strongly Disagree",
"ref": "strongly_disagree"
}
]
},
"validations": {
"required": false
}
},
{
"ref": "listen_question",
"title": "The police in my neighborhood listen to and take into account the concerns of local residents.",
"type": "multiple_choice",
"properties": {
"description": "Choose one",
"randomize": false,
"allow_multiple_selection": false,
"allow_other_choice": false,
"vertical_alignment": false,
"choices": [
{
"label": "Strongly Agree",
"ref": "strongly_agree"
},
{
"label": "Somewhat Agree",
"ref": "somewhat_agree"
},
{
"label": "Somewhat Disagree",
"ref": "somewhat_disagree"
},
{
"label": "Strongly Disagree",
"ref": "strongly_disagree"
}
]
},
"validations": {
"required": false
}
},
{
"ref": "actions_question",
"title": "The police in my neighborhood take actions that are good for residents of the neighborhood.",
"type": "multiple_choice",
"properties": {
"description": "Choose one",
"randomize": false,
"allow_multiple_selection": false,
"allow_other_choice": false,
"vertical_alignment": false,
"choices": [
{
"label": "Strongly Agree",
"ref": "strongly_agree"
},
{
"label": "Somewhat Agree",
"ref": "somewhat_agree"
},
{
"label": "Somewhat Disagree",
"ref": "somewhat_disagree"
},
{
"label": "Strongly Disagree",
"ref": "strongly_disagree"
}
]
},
"validations": {
"required": false
}
},
{
"ref": "bias_question",
"title": "The police in my neighborhood take actions based on fact, not their personal biases and opinions.",
"type": "multiple_choice",
"properties": {
"description": "Choose one",
"randomize": false,
"allow_multiple_selection": false,
"allow_other_choice": false,
"vertical_alignment": false,
"choices": [
{
"label": "Strongly Agree",
"ref": "strongly_agree"
},
{
"label": "Somewhat Agree",
"ref": "somewhat_agree"
},
{
"label": "Somewhat Disagree",
"ref": "somewhat_disagree"
},
{
"label": "Strongly Disagree",
"ref": "strongly_disagree"
}
]
},
"validations": {
"required": false
}
},
{
"ref": "gender",
"title": "What gender do you identify as?",
"type": "multiple_choice",
"properties": {
"description": "Choose one",
"randomize": false,
"allow_multiple_selection": false,
"allow_other_choice": false,
"vertical_alignment": false,
"choices": [
{
"label": "Male",
"ref": "male"
},
{
"label": "Female",
"ref": "female"
}
]
},
"validations": {
"required": false
}
},
{
"ref": "age",
"title": "How old are you?",
"type": "multiple_choice",
"properties": {
"description": "Please select one",
"randomize": false,
"allow_multiple_selection": false,
"allow_other_choice": false,
"vertical_alignment": false,
"choices": [
{
"label": "18-24",
"ref": "18-24"
},
{
"label": "25-34",
"ref": "25-34"
},
{
"label": "35-44",
"ref": "35-44"
},
{
"label": "45-54",
"ref": "45-54"
},
{
"label": "55-64",
"ref": "55-64"
},
{
"label": "65+",
"ref": "65+"
}
]
},
"validations": {
"required": false
}
},
{
"ref": "race",
"title": "What race do you identify as?",
"type": "multiple_choice",
"properties": {
"description": "Choose one",
"randomize": false,
"allow_multiple_selection": false,
"allow_other_choice": false,
"vertical_alignment": false,
"choices": [
{
"label": "White/Caucasian",
"ref": "white/caucasian"
},
{
"label": "Black/African-American",
"ref": "black/african-american"
},
{
"label": "Hispanic/Latino",
"ref": "hispanic/latino"
},
{
"label": "Asian/Asian-American",
"ref": "asian/asian-american"
},
{
"label": "Other",
"ref": "other"
}
]
},
"validations": {
"required": false
}
},
{
"ref": "hispanic",
"title": "Do you consider yourself Hispanic or Latino?",
"type": "multiple_choice",
"properties": {
"description": "Choose one",
"randomize": false,
"allow_multiple_selection": false,
"allow_other_choice": false,
"vertical_alignment": false,
"choices": [
{
"label": "Yes",
"ref": "yes_hispanic_ref"
},
{
"label": "No",
"ref": "no_hispanic_ref"
}
]
},
"validations": {
"required": false
}
},
{
"ref": "zip_code",
"title": "What is your zip code?",
"type": "number",
"properties": {
"description": "Eg: 10010"
}
},
{
"ref": "education",
"title": "What is the last grade or level of school you completed?",
"type": "multiple_choice",
"properties": {
"description": "Choose one",
"randomize": false,
"allow_multiple_selection": false,
"allow_other_choice": false,
"vertical_alignment": false,
"choices": [
{
"label": "Less than high school degree",
"ref": "less_than_high_school_degree"
},
{
"label": "High school graduate",
"ref": "high_school_graduate"
},
{
"label": "Some college",
"ref": "some_college"
},
{
"label": "College graduate / Bachelor's degree",
"ref": "college_graduate_/_bachelor's_degree"
},
{
"label": "Advanced degree",
"ref": "advanced_degree"
}
]
},
"validations": {
"required": false
}
},
{
"ref": "income",
"title": "Which category best represents your total annual household income?",
"type": "multiple_choice",
"properties": {
"description": "Choose one",
"randomize": false,
"allow_multiple_selection": false,
"allow_other_choice": false,
"vertical_alignment": false,
"choices": [
{
"label": "Less than $15,000",
"ref": "less_than_$15,000"
},
{
"label": "$15,000 to $29,999",
"ref": "$15,000_to_$29,999"
},
{
"label": "$30,000 to $49,999",
"ref": "$30,000_to_$49,999"
},
{
"label": "$50,000 to $74,999",
"ref": "$50,000_to_$74,999"
},
{
"label": "$75,000 to $99,999",
"ref": "$75,000_to_$99,999"
},
{
"label": "$100,000 to $149,999",
"ref": "$100,000_to_$149,999"
},
{
"label": "$150,000 or more",
"ref": "$150,000_or_more"
}
]
},
"validations": {
"required": false
}
}
],
"logic": [
{
"type": "field",
"ref": "race",
"actions": [
{
"action": "jump",
"details": {
"to": {
"type": "field",
"value": "zip_code"
}
},
"condition": {
"op": "equal",
"vars": [
{
"type": "field",
"value": "race"
},
{
"type": "constant",
"value": "hispanic/latino"
}
]
}
}
]
}
]
}
@forrest-ua
Copy link

HI @fhinson, to make it work you have to change this line to "op": "is", and this one to "type": "choice". A bit more examples you can find here: https://developer.typeform.com/create/logic-jumps/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment