Step 3: Create a counter

The next step in this example is to create a counter variable using an action of the Set Variable type.

Result of step 3

To create the counter:

  1. Drag an action interaction onto the canvas.
  2. Name the interaction. For example counter.
  3. Select Set Variable as the action type.
  4. In the Next field, select the condition interaction.
  5. On the Settings tab, enter the JavaScript to define a counter variable. For example:
    if (context.counter) {
        context.counter = context.counter + 1; 
    } 
    else { 
        context.counter = 1; 
    }
Step 4: Set up the responses that will be counted.