From 16895e1d646026a20211cff14d5c159bfcc4543a Mon Sep 17 00:00:00 2001 From: Rob Flaherty Date: Sat, 19 Jul 2014 14:23:11 -0400 Subject: [PATCH] final updates for v0.4 --- bower.json | 2 +- readme.md | 18 ++++-------------- riveted.min.js | 4 ++-- test/test.html | 10 ++++++++-- wp-plugin/riveted/js/riveted-wp.js | 4 ++-- 5 files changed, 17 insertions(+), 21 deletions(-) diff --git a/bower.json b/bower.json index a5b7997..2ed0d33 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "riveted", "main": "riveted.js", - "version": "0.3.2", + "version": "0.4.0", "homepage": "http://riveted.parsnip.io/", "authors": [ "Rob Flaherty" diff --git a/readme.md b/readme.md index 06fb234..26d562a 100644 --- a/readme.md +++ b/readme.md @@ -3,23 +3,11 @@ Riveted is a Google Analytics plugin that tracks how much time users spend activ It has no dependencies and supports Universal Analytics, Classic Google Analytics, and Google Tag Manager. -Implementation information is on the [project page](http://projects.parsnip.io/riveted/). This plugin is still in beta. +All instructions and information can be found on the [project page](http://projects.parsnip.io/riveted/). Background and more details can be found in this [blog post](http://parsnip.io/blog/riveted-measuring-active-time-in-google-analytics/). - -## Usage -```javascript -// Basic -riveted.init(); - -// With some options -riveted.init({ - reportInterval: 10, - idleTimeout: 20, - nonInteraction: false -}); -``` +There's also a blog post with information on [how to use the Google Analytics data that Riveted provides](https://medium.com/google-analytics/84d9981920da). ## WordPress Plugin Riveted is also available as a [WordPress plugin](http://wordpress.org/plugins/riveted/). @@ -49,6 +37,8 @@ If you have any questions you can find me on Twitter at [@robflaherty](https://t ## Changelog +0.4.0 (7/19/14): https://github.com/robflaherty/riveted/issues/10 + 0.3.2 (6/26/14): Fixed Google Tag Manager label. 0.3.1 (6/4/14): Fixed IE8 bug. diff --git a/riveted.min.js b/riveted.min.js index 777525f..8159ea6 100644 --- a/riveted.min.js +++ b/riveted.min.js @@ -1,7 +1,7 @@ /*! * @preserve - * riveted.js | v0.3.2 + * riveted.js | v0.4.0 * Copyright (c) 2014 Rob Flaherty (@robflaherty) * Licensed under the MIT license */ -var riveted=function(){function e(e){"function"==typeof ga&&(g=!0),"undefined"!=typeof _gaq&&"function"==typeof _gaq.push&&(p=!0),"undefined"!=typeof dataLayer&&"function"==typeof dataLayer.push&&(y=!0),e=e||{},s=parseInt(e.reportInterval,10)||5,f=parseInt(e.idleTimeout,10)||30,m="nonInteraction"in e&&(e.nonInteraction===!1||"false"===e.nonInteraction)?!1:!0,t(document,"keydown",l),t(document,"click",l),t(window,"mousemove",n(l,500)),t(window,"scroll",n(l,500)),t(document,"visibilitychange",r),t(document,"webkitvisibilitychange",r)}function n(e,n){var t,i,a,o=null,r=0,u=function(){r=new Date,o=null,a=e.apply(t,i)};return function(){var c=new Date;r||(r=c);var d=n-(c-r);return t=this,i=arguments,0>=d?(clearTimeout(o),o=null,r=c,a=e.apply(t,i)):o||(o=setTimeout(u,d)),a}}function t(e,n,t){e.addEventListener?e.addEventListener(n,t,!1):e.attachEvent?e.attachEvent("on"+n,t):e["on"+n]=t}function i(e){y?dataLayer.push({event:"RivetedTiming",eventCategory:"Riveted",timingVar:"First Interaction",timingValue:e}):(g&&ga("send","timing","Riveted","First Interaction",e),p&&_gaq.push(["_trackTiming","Riveted","First Interaction",e,null,100]))}function a(e){y?dataLayer.push({event:"Riveted",eventCategory:"Riveted",eventAction:"Time Spent",eventLabel:e,eventValue:s,eventNonInteraction:m}):(g&&ga("send","event","Riveted","Time Spent",e.toString(),s,{nonInteraction:m}),p&&_gaq.push(["_trackEvent","Riveted","Time Spent",e.toString(),s,m]))}function o(){clearTimeout(L),c()}function r(){(document.hidden||document.webkitHidden)&&o()}function u(){h+=1,h>0&&h%s===0&&a(h)}function c(){T=!0,clearTimeout(R)}function d(){T=!1,clearTimeout(R),R=setInterval(u,1e3)}function v(){var e=new Date,n=e-w;I=!0,i(n),R=setInterval(u,1e3)}function l(){I||v(),T&&d(),clearTimeout(L),L=setTimeout(o,1e3*f+100)}var s,f,m,g,p,y,I=!1,T=!1,h=0,w=new Date,R=null,L=null;return{init:e,trigger:l,setIdle:o}}(); \ No newline at end of file +var riveted=function(){function e(e){"function"==typeof ga&&(y=!0),"undefined"!=typeof _gaq&&"function"==typeof _gaq.push&&(T=!0),"undefined"!=typeof dataLayer&&"function"==typeof dataLayer.push&&(I=!0),e=e||{},m=parseInt(e.reportInterval,10)||5,g=parseInt(e.idleTimeout,10)||30,"function"==typeof e.eventHandler&&(f=e.eventHandler),"function"==typeof e.userTimingHandler&&(s=e.userTimingHandler),p="nonInteraction"in e&&(e.nonInteraction===!1||"false"===e.nonInteraction)?!1:!0,t(document,"keydown",v),t(document,"click",v),t(window,"mousemove",n(v,500)),t(window,"scroll",n(v,500)),t(document,"visibilitychange",o),t(document,"webkitvisibilitychange",o)}function n(e,n){var t,i,o,a=null,r=0,u=function(){r=new Date,a=null,o=e.apply(t,i)};return function(){var c=new Date;r||(r=c);var d=n-(c-r);return t=this,i=arguments,0>=d?(clearTimeout(a),a=null,r=c,o=e.apply(t,i)):a||(a=setTimeout(u,d)),o}}function t(e,n,t){e.addEventListener?e.addEventListener(n,t,!1):e.attachEvent?e.attachEvent("on"+n,t):e["on"+n]=t}function i(){clearTimeout(b),r()}function o(){(document.hidden||document.webkitHidden)&&i()}function a(){L+=1,L>0&&L%m===0&&f(L)}function r(){w=!0,clearTimeout(_)}function u(){i(),R=!0}function c(){R=!1}function d(){w=!1,clearTimeout(_),_=setInterval(a,1e3)}function l(){var e=new Date,n=e-k;h=!0,s(n),_=setInterval(a,1e3)}function v(){R||(h||l(),w&&d(),clearTimeout(b),b=setTimeout(i,1e3*g+100))}var f,s,m,g,p,y,T,I,h=!1,w=!1,R=!1,L=0,k=new Date,_=null,b=null;return s=function(e){I?dataLayer.push({event:"RivetedTiming",eventCategory:"Riveted",timingVar:"First Interaction",timingValue:e}):(y&&ga("send","timing","Riveted","First Interaction",e),T&&_gaq.push(["_trackTiming","Riveted","First Interaction",e,null,100]))},f=function(e){I?dataLayer.push({event:"Riveted",eventCategory:"Riveted",eventAction:"Time Spent",eventLabel:e,eventValue:m,eventNonInteraction:p}):(y&&ga("send","event","Riveted","Time Spent",e.toString(),m,{nonInteraction:p}),T&&_gaq.push(["_trackEvent","Riveted","Time Spent",e.toString(),m,p]))},{init:e,trigger:v,setIdle:i,on:c,off:u}}(); \ No newline at end of file diff --git a/test/test.html b/test/test.html index 867b2f9..a734158 100644 --- a/test/test.html +++ b/test/test.html @@ -23,12 +23,18 @@ //ga = undefined; - + diff --git a/wp-plugin/riveted/js/riveted-wp.js b/wp-plugin/riveted/js/riveted-wp.js index d192eb4..2a1c22a 100644 --- a/wp-plugin/riveted/js/riveted-wp.js +++ b/wp-plugin/riveted/js/riveted-wp.js @@ -1,7 +1,7 @@ /*! * @preserve - * riveted.js | v0.3.2 + * riveted.js | v0.4.0 * Copyright (c) 2014 Rob Flaherty (@robflaherty) * Licensed under the MIT license */ -var riveted=function(){function e(e){"function"==typeof ga&&(g=!0),"undefined"!=typeof _gaq&&"function"==typeof _gaq.push&&(p=!0),"undefined"!=typeof dataLayer&&"function"==typeof dataLayer.push&&(y=!0),e=e||{},s=parseInt(e.reportInterval,10)||5,f=parseInt(e.idleTimeout,10)||30,m="nonInteraction"in e&&(e.nonInteraction===!1||"false"===e.nonInteraction)?!1:!0,t(document,"keydown",l),t(document,"click",l),t(window,"mousemove",n(l,500)),t(window,"scroll",n(l,500)),t(document,"visibilitychange",r),t(document,"webkitvisibilitychange",r)}function n(e,n){var t,i,a,o=null,r=0,u=function(){r=new Date,o=null,a=e.apply(t,i)};return function(){var c=new Date;r||(r=c);var d=n-(c-r);return t=this,i=arguments,0>=d?(clearTimeout(o),o=null,r=c,a=e.apply(t,i)):o||(o=setTimeout(u,d)),a}}function t(e,n,t){e.addEventListener?e.addEventListener(n,t,!1):e.attachEvent?e.attachEvent("on"+n,t):e["on"+n]=t}function i(e){y?dataLayer.push({event:"RivetedTiming",eventCategory:"Riveted",timingVar:"First Interaction",timingValue:e}):(g&&ga("send","timing","Riveted","First Interaction",e),p&&_gaq.push(["_trackTiming","Riveted","First Interaction",e,null,100]))}function a(e){y?dataLayer.push({event:"Riveted",eventCategory:"Riveted",eventAction:"Time Spent",eventLabel:e,eventValue:s,eventNonInteraction:m}):(g&&ga("send","event","Riveted","Time Spent",e.toString(),s,{nonInteraction:m}),p&&_gaq.push(["_trackEvent","Riveted","Time Spent",e.toString(),s,m]))}function o(){clearTimeout(L),c()}function r(){(document.hidden||document.webkitHidden)&&o()}function u(){h+=1,h>0&&h%s===0&&a(h)}function c(){T=!0,clearTimeout(R)}function d(){T=!1,clearTimeout(R),R=setInterval(u,1e3)}function v(){var e=new Date,n=e-w;I=!0,i(n),R=setInterval(u,1e3)}function l(){I||v(),T&&d(),clearTimeout(L),L=setTimeout(o,1e3*f+100)}var s,f,m,g,p,y,I=!1,T=!1,h=0,w=new Date,R=null,L=null;return{init:e,trigger:l,setIdle:o}}();riveted.init(riveted_options); \ No newline at end of file +var riveted=function(){function e(e){"function"==typeof ga&&(y=!0),"undefined"!=typeof _gaq&&"function"==typeof _gaq.push&&(T=!0),"undefined"!=typeof dataLayer&&"function"==typeof dataLayer.push&&(I=!0),e=e||{},m=parseInt(e.reportInterval,10)||5,g=parseInt(e.idleTimeout,10)||30,"function"==typeof e.eventHandler&&(f=e.eventHandler),"function"==typeof e.userTimingHandler&&(s=e.userTimingHandler),p="nonInteraction"in e&&(e.nonInteraction===!1||"false"===e.nonInteraction)?!1:!0,t(document,"keydown",v),t(document,"click",v),t(window,"mousemove",n(v,500)),t(window,"scroll",n(v,500)),t(document,"visibilitychange",o),t(document,"webkitvisibilitychange",o)}function n(e,n){var t,i,o,a=null,r=0,u=function(){r=new Date,a=null,o=e.apply(t,i)};return function(){var c=new Date;r||(r=c);var d=n-(c-r);return t=this,i=arguments,0>=d?(clearTimeout(a),a=null,r=c,o=e.apply(t,i)):a||(a=setTimeout(u,d)),o}}function t(e,n,t){e.addEventListener?e.addEventListener(n,t,!1):e.attachEvent?e.attachEvent("on"+n,t):e["on"+n]=t}function i(){clearTimeout(b),r()}function o(){(document.hidden||document.webkitHidden)&&i()}function a(){L+=1,L>0&&L%m===0&&f(L)}function r(){w=!0,clearTimeout(_)}function u(){i(),R=!0}function c(){R=!1}function d(){w=!1,clearTimeout(_),_=setInterval(a,1e3)}function l(){var e=new Date,n=e-k;h=!0,s(n),_=setInterval(a,1e3)}function v(){R||(h||l(),w&&d(),clearTimeout(b),b=setTimeout(i,1e3*g+100))}var f,s,m,g,p,y,T,I,h=!1,w=!1,R=!1,L=0,k=new Date,_=null,b=null;return s=function(e){I?dataLayer.push({event:"RivetedTiming",eventCategory:"Riveted",timingVar:"First Interaction",timingValue:e}):(y&&ga("send","timing","Riveted","First Interaction",e),T&&_gaq.push(["_trackTiming","Riveted","First Interaction",e,null,100]))},f=function(e){I?dataLayer.push({event:"Riveted",eventCategory:"Riveted",eventAction:"Time Spent",eventLabel:e,eventValue:m,eventNonInteraction:p}):(y&&ga("send","event","Riveted","Time Spent",e.toString(),m,{nonInteraction:p}),T&&_gaq.push(["_trackEvent","Riveted","Time Spent",e.toString(),m,p]))},{init:e,trigger:v,setIdle:i,on:c,off:u}}();riveted.init(riveted_options); \ No newline at end of file