Is it true that the order of your events matters?

Kade Schemahorn shared this question 4 years ago

I ran into the following issue. First, I created a variable with value Y. Then, I put two events on a single hotspot, as in configuration 1.


1. Link to another page

2. Set value of a variable to X

When I clicked the hotspot, the link worked (1st event), but the value of the variable remained Y.

I finally figured out that if I flipped the order of the events, it works...


1. Set value of a variable to X

2. Link to another page

I am guessing that when I had it set to configuration 1, the system flow went something like this:

- Click hotspot (ON-CLICK interaction)

- Link to another page (ON PAGE UNLOAD interaction)

- The 2nd event never runs because of the ON PAGE UNLOAD interaction

If this is the case, would there be any harm in simplifying it so that all events run, no matter what, before the events tied to any other interactions run? They could stack up in a queue. Something like this:

- Click hotspot (ON-CLICK interaction)

- Link to another page

- Set value on variable

- Now acknowledge that an ON PAGE UNLOAD interaction occurred and deal with that

The one issue I can see there is performance and seeing flickering as multiple events run after the page has already been switched. But I think the headache of ordering your events is a much bigger problem than that, especially as prototypes get complex. Or perhaps I have missed the mark entirely. Let me know. Thanks so much.