-2

I am new to MC and I am given the task to create a survey where the questions will be posted to the end-user.

  1. The questions in the survey should get navigated based on the response in the previous question of the Survey? How can we do this? And where exactly should I have to build this?

For example: This is the first question and in case if I give 5 stars this will navigate me to the 2nd picture. Else, the question is going to be different if I give less rating. enter image description here

enter image description here

  1. How are the responses in this survey tagged back to the MC. What is the exact ways through which we can do this?

A overview over this is more than enough for me to complete this requirement.

EDIT: (What I have tried so far) I have created a cloud page, but I am not sure on how to navigate based on the response.

1
  • 1
    What have you tried so far? Questions about requirements or objectives should demonstrate the work or research you’ve done. Providing implementations based on a list of requirements is not a goal of this community.
    – zuzannamj
    Apr 19 at 8:18

1 Answer 1

2

So if you want to do it in the form submit way (whole page refresh), You can create one cloud page instead of multiple cloud pages (one for each question). the trick is that if you don't specify action in < form > it should just submit to the same cloud page. so you want to capture the form data in RequestParameter, include the previous questionid and answer, so you can dynamically create HTML element with next questionid as well as creating html elements for next question depend on previous answer.

[%

VAR @subscriberKey, @pageId, @pageAnswer, @insertCount, @submitAction

SET @subscriberKey = AttributeValue(_subscriberKey)

SET @submitAction = RequestParameter("submitAction") 

SET @questionId = RequestParameter("questionId") 

SET @questionAnswer = RequestParameter("pageAnswer") 


/* Insert answers to DE */

IF @submitAction == "submit" AND NOT EMPTY(@questionId) AND NOT EMPTY(@questionAnswer) THEN

SET @insertCount = insertData("MyDE","SubscriberKey", @subscriberKey, "questionId",@questionId, "questionAnswer",@questionAnswer)

ENDIF

IF @questionId == "" THEN
   /* first time page load, it is empty, so it should be set to 1 */
    set @questionId = "1"
ELSE
    /* Increase questionId by 1 */
    set @questionId = FormatNumber(@questionId, "G") + 1
ENDIF

%]

<html>
<head>
    <script src="" /> // load your js library
    
    
</head>
<body>

<form>
    <input id="submitAction" name="submitAction" type="hidden" value="submit" />
    <input id="questionId" name="questionId" type="hidden" value="%%=v(@questionId)=%%" />

    [% 
        IF @questionId == "1" THEN
    %]
    <div>

        <!-- Create HTMl elements for question 1, render stars element etc -->
    </div>
    [% 
        ENDIF
    %]


    [% 
        IF @questionId == "2" THEN
    %]
    <div>
        [% 
            IF @questionAnswer == "choiceA" THEN
        %]

        <!-- Create HTMl elements for question 2 base on question 1's answer of Choice A -->

        [% 
            ELSEIF @questionAnswer == "choiceB" THEN
        %]

        <!-- Create HTMl elements for question 2 base on question 1's answer of Choice B -->
        
        
        [% 
            ENDIF
        %]

        
    </div>
    [% 
        ENDIF
    %]


    <!-- This input captures the answer for current question, you should use JS to populate the answer from html element interaction, it can be visible or hidden depend on the design -->

    <input id="questionAnswer" name="questionAnswer" type="text" value="" />


    <input type="submit" value="submit" />
</form>

<script>
// load your js code etc
</script>

</body>
</html>

Another way to design this is ajax style: create two cloud pages, 1st page to render question and answers in a div, and use js e.g. jquery to submit form inputs to 2nd cloud page, 2nd cloud page is just a "request process" page that takes input parameter , update DE, then response with JSON data, then in 1st page you can capture the ajax response then render the next question, rinse and repeat until you have all the questions html code designed and handled by ajax response.

Not the answer you're looking for? Browse other questions tagged .