Skip to content

Commit e1810a4

Browse files
committed
Adding option to disable User Timing events. robflaherty#14
1 parent bf45367 commit e1810a4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

jquery.scrolldepth.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
var defaults = {
1212
elements: [],
1313
minHeight: 0,
14-
percentage: true
14+
percentage: true,
15+
userTiming: true
1516
},
1617

1718
$window = $(window),
@@ -44,23 +45,23 @@
4445
if (typeof dataLayer !== "undefined" && typeof dataLayer.push === "function") {
4546
dataLayer.push({'event':'ScrollDistance', 'eventCategory':'Scroll Depth', 'eventAction': action, 'eventLabel': label, 'eventValue': 1, 'eventNonInteraction': true});
4647

47-
if (arguments.length > 2) {
48+
if (options.userTiming && arguments.length > 2) {
4849
dataLayer.push({'event':'ScrollTiming', 'eventCategory':'Scroll Depth', 'eventAction': action, 'eventLabel': label, 'eventTiming': timing});
4950
}
5051
} else {
5152

5253
if (typeof ga === "function") {
5354
ga('send', 'event', 'Scroll Depth', action, label, 1, {'nonInteraction': 1});
5455

55-
if (arguments.length > 2) {
56+
if (options.userTiming && arguments.length > 2) {
5657
ga('send', 'timing', 'Scroll Depth', action, timing, label);
5758
}
5859
}
5960

6061
if (typeof _gaq !== "undefined" && typeof _gaq.push === "function") {
6162
_gaq.push(['_trackEvent', 'Scroll Depth', action, label, 1, true]);
6263

63-
if (arguments.length > 2) {
64+
if (options.userTiming && arguments.length > 2) {
6465
_gaq.push(['_trackTiming', 'Scroll Depth', action, timing, label, 100]);
6566
}
6667
}

0 commit comments

Comments
 (0)