Considerations for using the After Every Step
trigger
In almost all cases, when you create step attributes, you are interested in the current
context of the session. You create attributes to monitor the current data that is available as of
the current step. As a result, the After Every Step
trigger is rarely
used.
In the example below, the After Every Step
trigger
is used. This scenario mirrors the After Every Hit
trigger
usage, except that it applies to steps instead of hits.
The After Every Step
trigger is useful when you
must compare the current state with the previous state. For example,
suppose you want to know whether users clicked the same object twice
in a row.
- To test this scenario, you must know both the object currently being click, and the previously clicked object. If the events that track both the current and previous states fire on the same trigger, they are updated at the same time and therefore always have the same value.
- However, if the previous state event fires just after the current
state value by using the
After Every Step
trigger, the previous state event is not updated when the current state event fires. Therefore, you can compare the current state with the previous state by using an event that fires on theEvery Step
trigger.
Note: Form messages contain the
currState
and prevState
properties
within a step. The currState
property refers to the
final value of the form field after editing, and prevState
refers
to the default value before editing. These references do not work
for testing if the same action occurred twice, since the default value
can be reset to blank each time it is accessed.