|
1 | 1 | /*!
|
2 | 2 | * @preserve
|
3 |
| - * jquery.scrolldepth.js | v1.0 |
4 |
| - * Copyright (c) 2016 Rob Flaherty (@robflaherty) |
| 3 | + * jquery.scrolldepth.js | v1.2.0 |
| 4 | + * Copyright (c) 2020 Rob Flaherty (@robflaherty) |
5 | 5 | * Licensed under the MIT and GPL licenses.
|
6 | 6 | */
|
7 | 7 |
|
|
102 | 102 |
|
103 | 103 | var command = options.trackerName ? (options.trackerName + '.send') : 'send';
|
104 | 104 |
|
105 |
| - if (globalSiteTag) { |
| 105 | + if (standardEventHandler) { |
| 106 | + |
| 107 | + standardEventHandler({'event': 'ScrollDistance', 'eventCategory': 'Scroll Depth', 'eventAction': action, 'eventLabel': label, 'eventValue': 1, 'eventNonInteraction': options.nonInteraction}); |
| 108 | + |
| 109 | + if (options.pixelDepth && arguments.length > 2 && scrollDistance > lastPixelDepth) { |
| 110 | + lastPixelDepth = scrollDistance; |
| 111 | + standardEventHandler({'event': 'ScrollDistance', 'eventCategory': 'Scroll Depth', 'eventAction': 'Pixel Depth', 'eventLabel': rounded(scrollDistance), 'eventValue': 1, 'eventNonInteraction': options.nonInteraction}); |
| 112 | + } |
| 113 | + |
| 114 | + if (options.userTiming && arguments.length > 3) { |
| 115 | + standardEventHandler({'event': 'ScrollTiming', 'eventCategory': 'Scroll Depth', 'eventAction': action, 'eventLabel': label, 'eventTiming': timing}); |
| 116 | + } |
| 117 | + |
| 118 | + } else if (globalSiteTag) { |
106 | 119 |
|
107 | 120 | gtag('event', action, {
|
108 | 121 | 'event_category': 'Scroll Depth',
|
|
130 | 143 | });
|
131 | 144 | }
|
132 | 145 |
|
133 |
| - } else if (standardEventHandler) { |
134 |
| - |
135 |
| - standardEventHandler({'event': 'ScrollDistance', 'eventCategory': 'Scroll Depth', 'eventAction': action, 'eventLabel': label, 'eventValue': 1, 'eventNonInteraction': options.nonInteraction}); |
136 |
| - |
137 |
| - if (options.pixelDepth && arguments.length > 2 && scrollDistance > lastPixelDepth) { |
138 |
| - lastPixelDepth = scrollDistance; |
139 |
| - standardEventHandler({'event': 'ScrollDistance', 'eventCategory': 'Scroll Depth', 'eventAction': 'Pixel Depth', 'eventLabel': rounded(scrollDistance), 'eventValue': 1, 'eventNonInteraction': options.nonInteraction}); |
140 |
| - } |
141 |
| - |
142 |
| - if (options.userTiming && arguments.length > 3) { |
143 |
| - standardEventHandler({'event': 'ScrollTiming', 'eventCategory': 'Scroll Depth', 'eventAction': action, 'eventLabel': label, 'eventTiming': timing}); |
144 |
| - } |
145 |
| - |
146 | 146 | } else {
|
147 | 147 |
|
148 | 148 | if (universalGA) {
|
|
0 commit comments