Skip to content

Commit 226ba67

Browse files
committed
If both classic and universal GA are defined, submit events to both
1 parent 4e3f91a commit 226ba67

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

jquery.scrolldepth.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,22 @@
4343
function sendEvent(action, label, timing) {
4444
if (!options.testing) {
4545

46-
if ( typeof(ga) == "function" || typeof(ga) == "object" ) {
46+
if (typeof(ga) !== "undefined") {
4747
ga('send', 'event', 'Scroll Depth', action, label, 1, {'nonInteraction': 1});
48-
} else if ( typeof(_gaq) == "function" || typeof(_gaq) == "object" ) {
49-
_gaq.push(['_trackEvent', 'Scroll Depth', action, label, 1, true]);
50-
}
5148

52-
if (arguments.length > 2) {
53-
if ( typeof(ga) == "function" || typeof(ga) == "object" ) {
49+
if (arguments.length > 2) {
5450
ga('send', 'timing', 'Scroll Depth', action, timing, label);
55-
} else if ( typeof(_gaq) == "function" || typeof(_gaq) == "object" ) {
51+
}
52+
53+
}
54+
55+
if (typeof(_gaq) !== "undefined") {
56+
_gaq.push(['_trackEvent', 'Scroll Depth', action, label, 1, true]);
57+
58+
if (arguments.length > 2) {
5659
_gaq.push(['_trackTiming', 'Scroll Depth', action, timing, label, 100]);
5760
}
61+
5862
}
5963

6064
} else {

0 commit comments

Comments
 (0)