A pageview should be submitted to an analytics tracker whenever changedItem
is triggered. Its payload should look like: {item: 'name of item', empty: Boolean}
Emits changedItem
events. Their payload is {item: 'foo'}
.
Listens for changedItem
events and then emits the data via itemData
with {item: 'foo', data: []}
.
Whether or not Item Foo has any data isn't known when changedItem
is triggered. That information is in the itemData
event payload which occurs after itemData
.
It seems to me, I need to know a) when all of these events have occurred b) the values of each event.
If I had both those items, I could do something like:
on(['changedItem', 'itemData'], function (changedItem, itemData) {
trigger('pageview', {
item: changedItem.item,
empty: !itemData.data.length
});
})
While it might appear that I could get the item
information from itemData
's payload, it isn't so. itemData
is triggered many times, not just when changedItem
occurs. Simply observing itemData
wouldn't accurately track what we wish to track.
Be notified when a user has gone inactive. One goal of this information is to track how long the user was active in a given section.
User is inactive if:
- Goes 60 seconds without page interaction
- Using the mouse (
mousemove
,click
, etc) - Interacting with the keyboard (
keydown
,keyup
, etc) - Interacting with any form elements (
select#change
,form#submit
, etc)
- Using the mouse (
- Or, as soon as either of these occur
blur
onwindow
element- Page Visibility API says page is
hidden
I'm not rightly sure I understand the first scenario though. Seems like you maybe need another event that is triggered only when changedItem is triggered, or to pass some sort of identifier with itemData that says "this was triggered in response to a changedItem event".