Skip to content

Commit 1424d3b

Browse files
committed
added google non interaction event flag to options
1 parent b3924ee commit 1424d3b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

jquery.scrolldepth.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
elements: [],
1414
percentage: true,
1515
userTiming: true,
16-
pixelDepth: true
16+
pixelDepth: true,
17+
nonInteraction: true
1718
};
1819

1920
var $window = $(window),
@@ -66,11 +67,11 @@
6667

6768
if (googleTagManager) {
6869

69-
dataLayer.push({'event': 'ScrollDistance', 'eventCategory': 'Scroll Depth', 'eventAction': action, 'eventLabel': label, 'eventValue': 1, 'eventNonInteraction': true});
70+
dataLayer.push({'event': 'ScrollDistance', 'eventCategory': 'Scroll Depth', 'eventAction': action, 'eventLabel': label, 'eventValue': 1, 'eventNonInteraction': options.nonInteraction});
7071

7172
if (options.pixelDepth && arguments.length > 2 && scrollDistance > lastPixelDepth) {
7273
lastPixelDepth = scrollDistance;
73-
dataLayer.push({'event': 'ScrollDistance', 'eventCategory': 'Scroll Depth', 'eventAction': 'Pixel Depth', 'eventLabel': rounded(scrollDistance), 'eventValue': 1, 'eventNonInteraction': true});
74+
dataLayer.push({'event': 'ScrollDistance', 'eventCategory': 'Scroll Depth', 'eventAction': 'Pixel Depth', 'eventLabel': rounded(scrollDistance), 'eventValue': 1, 'eventNonInteraction': options.nonInteraction});
7475
}
7576

7677
if (options.userTiming && arguments.length > 3) {
@@ -81,11 +82,11 @@
8182

8283
if (universalGA) {
8384

84-
ga('send', 'event', 'Scroll Depth', action, label, 1, {'nonInteraction': 1});
85+
ga('send', 'event', 'Scroll Depth', action, label, 1, {'nonInteraction': options.nonInteraction ? 1 : 0});
8586

8687
if (options.pixelDepth && arguments.length > 2 && scrollDistance > lastPixelDepth) {
8788
lastPixelDepth = scrollDistance;
88-
ga('send', 'event', 'Scroll Depth', 'Pixel Depth', rounded(scrollDistance), 1, {'nonInteraction': 1});
89+
ga('send', 'event', 'Scroll Depth', 'Pixel Depth', rounded(scrollDistance), 1, {'nonInteraction': options.nonInteraction ? 1 : 0});
8990
}
9091

9192
if (options.userTiming && arguments.length > 3) {
@@ -96,11 +97,11 @@
9697

9798
if (classicGA) {
9899

99-
_gaq.push(['_trackEvent', 'Scroll Depth', action, label, 1, true]);
100+
_gaq.push(['_trackEvent', 'Scroll Depth', action, label, 1, options.nonInteraction]);
100101

101102
if (options.pixelDepth && arguments.length > 2 && scrollDistance > lastPixelDepth) {
102103
lastPixelDepth = scrollDistance;
103-
_gaq.push(['_trackEvent', 'Scroll Depth', 'Pixel Depth', rounded(scrollDistance), 1, true]);
104+
_gaq.push(['_trackEvent', 'Scroll Depth', 'Pixel Depth', rounded(scrollDistance), 1, options.nonInteraction]);
104105
}
105106

106107
if (options.userTiming && arguments.length > 3) {

0 commit comments

Comments
 (0)