Within my js file, I have the following code snippet:
;
var tracker = (function () {
var _track = function(userId, atts) {
alert(userId);
};
return {
track: function (userId, atts) {
_track(userId, atts);
}
}
}());
I'm implementing the javascript using a common pattern observed in other services:
<script>
(function(w, d, js) {
var f = d.getElementsByTagName('script')[0],
s = d.createElement('script');
s.async = true;
s.src = js;
f.parentNode.insertBefore(s, f);
})(window, document, '//localhost/WebApp1/Assets/tracker/tracker.js');
var userAtts = {
'foo': 1,
'bar': 2,
'some-invalid-identifier': 3
};
$(document).ready(function() {
tracker.track(3213, userAtts);
});
</script>
Despite this setup, an error message appears:
(index):107 Uncaught ReferenceError: tracker is not defined.
The root cause of this issue eludes me.