Skip to content

Commit

Permalink
Merge branch 'v0.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
robflaherty committed Jun 13, 2015
2 parents a01f382 + ecdfdb6 commit acbd07a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "riveted",
"main": "riveted.js",
"version": "0.5.0",
"version": "0.6.0",
"homepage": "http://riveted.parsnip.io/",
"authors": [
"Rob Flaherty"
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ If you have any questions you can find me on Twitter at [@robflaherty](https://t

## Changelog

0.6.0 (6/12/15): Added reset method and option for custom GA tracker.

0.5.0 (4/14/15): Option for custom GA global name. Fixes problem with Yoast WP plugin.

0.4.0 (7/19/14): https://github.com/robflaherty/riveted/issues/10
Expand Down
28 changes: 22 additions & 6 deletions riveted.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* @preserve
* riveted.js | v0.5.0
* riveted.js | v0.6.0
* Copyright (c) 2015 Rob Flaherty (@robflaherty)
* Licensed under the MIT license
*/
Expand All @@ -21,6 +21,7 @@ var riveted = (function() {
nonInteraction,
universalGA,
classicGA,
universalSendCommand,
googleTagManager,
gaGlobal;

Expand Down Expand Up @@ -49,13 +50,18 @@ var riveted = (function() {
googleTagManager = true;
}

if ('tracker' in options && typeof options.tracker === 'string') {
universalSendCommand = options.tracker + '.send';
} else {
universalSendCommand = 'send';
}

if (typeof options.eventHandler == 'function') {
sendEvent = options.eventHandler;
sendEvent = options.eventHandler;
}

if (typeof options.userTimingHandler == 'function') {
sendUserTiming = options.userTimingHandler;
sendUserTiming = options.userTimingHandler;
}

if ('nonInteraction' in options && (options.nonInteraction === false || options.nonInteraction === 'false')) {
Expand Down Expand Up @@ -140,7 +146,7 @@ var riveted = (function() {
} else {

if (universalGA) {
window[gaGlobal]('send', 'timing', 'Riveted', 'First Interaction', timingValue);
window[gaGlobal](universalSendCommand, 'timing', 'Riveted', 'First Interaction', timingValue);
}

if (classicGA) {
Expand All @@ -164,7 +170,7 @@ var riveted = (function() {
} else {

if (universalGA) {
window[gaGlobal]('send', 'event', 'Riveted', 'Time Spent', time.toString(), reportInterval, {'nonInteraction': nonInteraction});
window[gaGlobal](universalSendCommand, 'event', 'Riveted', 'Time Spent', time.toString(), reportInterval, {'nonInteraction': nonInteraction});
}

if (classicGA) {
Expand Down Expand Up @@ -231,6 +237,15 @@ var riveted = (function() {

}

function resetRiveted() {
startTime = new Date();
clockTime = 0;
started = false;
stopped = false;
clearTimeout(clockTimer);
clearTimeout(idleTimer);
}

function trigger() {

if (turnedOff) {
Expand All @@ -254,7 +269,8 @@ var riveted = (function() {
trigger: trigger,
setIdle: setIdle,
on: turnOn,
off: turnOff
off: turnOff,
reset: resetRiveted
};

})();
4 changes: 2 additions & 2 deletions riveted.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
};

var __gaTracker = function(params) {
var args = Array.prototype.slice.call(arguments, 1);
var args = Array.prototype.slice.call(arguments, 0);
console.log("__gaTracker(" + args.join(',') + ");");
};

var ga = function(params) {
var args = Array.prototype.slice.call(arguments, 0);
console.log("ga(" + args.join(',') + ");");
};

Expand All @@ -29,7 +34,8 @@
reportInterval: 2,
idleTimeout: 5,
nonInteraction: false,
gaGlobal: '__gaTracker'
//gaGlobal: '__gaTracker',
tracker: 'fooo'

/*eventHandler: function(event) {
console.log(event);
Expand Down

0 comments on commit acbd07a

Please sign in to comment.