Issues with implementing Bacon.JS to find average time spent per user on third party widget

8 views
Skip to first unread message

ANKIT NARAYAN

unread,
Dec 24, 2014, 2:43:38 PM12/24/14
to bac...@googlegroups.com

I currently developing a third party widget for online publishers and would like to track its performance on different websites. I thought of implementing Upworthy's code (http://upworthy.github.io/2014/06/implementing-attention-minutes-part-1/) for calculating average time spent per user on my widget only. So I decided to implement it in 3 steps:

  1. Start my "focus" event when my widget is visible in the viewport only (my widget is generally embedded at the bottom of the article)
  2. Next, as shown in Upworthy's method, I will merge my customised "focus" event with blur event to develop an isFocused event.
  3. Then, I can implement their recentlyActive method to find out if users are clicking on widget or not i.e if they are interacting with my widget.

I have implemented the above and source code can be found here: http://jsfiddle.net/q21gzjmf/13/

However, if you scroll down at the bottom you will find that time spent is calculated as 0 and doesn't update itself dynamically unlike Upworthy's implementation shown here http://jsfiddle.net/zanes/mbGBr/. I'm very new to the concept of Functional Reactive programming and still trying to get my head around Bacon.JS so I'm sure I must have made a very silly, conceptual mistake but I'm here to learn. Any help will be greatly appreciated.

Reply all
Reply to author
Forward
0 new messages