Skip to content

Commit cf284ab

Browse files
committed
removing testing option. using mock GA functions in test file instead
1 parent f7abb7d commit cf284ab

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

jquery.scrolldepth.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
var defaults = {
1212
elements: [],
1313
minHeight: 0,
14-
percentage: true,
15-
testing: false
14+
percentage: true
1615
},
1716

1817
$window = $(window),
@@ -41,7 +40,6 @@
4140
*/
4241

4342
function sendEvent(action, label, timing) {
44-
if (!options.testing) {
4543

4644
if (typeof dataLayer !== "undefined" && typeof dataLayer.push === "function") {
4745
dataLayer.push({'event':'ScrollDistance', 'eventCategory':'Scroll Depth', 'eventAction': action, 'eventLabel': label, 'eventValue': 1, 'eventNonInteraction': true});
@@ -67,10 +65,6 @@
6765
}
6866
}
6967
}
70-
71-
} else {
72-
$('#console').html(action + ': ' + label);
73-
}
7468
}
7569

7670
function calculateMarks(docHeight) {

test/index.html

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,29 @@ <h1>jQuery Scroll Depth Test Page</h1>
1111
<div id="main" style="background: #ccc; height: 2000px">#main</div>
1212
<footer style="background: #999; height: 200px; display: block;">footer</footer>
1313

14-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
15-
<script src="../jquery.scrolldepth.min.js"></script>
14+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
15+
<script src="../jquery.scrolldepth.js"></script>
1616
<script>
17+
var _gaq = {};
18+
_gaq.push = function(data) {
19+
console.log("_gaq.push(" + data + ");");
20+
};
21+
22+
var dataLayer = {};
23+
dataLayer.push = function(data) {
24+
console.log("dataLayer.push(" + JSON.stringify(data) + ");");
25+
};
26+
27+
var ga = function(params) {
28+
var args = Array.prototype.slice.call(arguments, 1);
29+
console.log("ga(" + args.join(',') + ");");
30+
};
31+
32+
_gaq = undefined;
33+
dataLayer = undefined;
34+
//ga = undefined;
35+
1736
$.scrollDepth({
18-
testing: true,
1937
elements: ['#main', 'footer']
2038
});
2139
</script>

0 commit comments

Comments
 (0)