️ Blazing fast, dead simple, and minimal analytics solution for websites.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
695 B

// Include Socket.io script before this
// https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js
(function (history) {
var pushState = history.pushState;
history.pushState = function (state) {
if (typeof history.onpushstate == "function") {
history.onpushstate({
state: state
});
};
visitorData.page = document.URL;
return pushState.apply(history, arguments);
};
})(window.history);
7 years ago
var socket = io('<your-server-address>');
var visitorData = {
referringSite: document.referrer,
domain: window.parent.location.hostname,
page: document.URL,
userAgent: navigator.userAgent
}
var emit = function () {
socket.emit('visitor-data', visitorData);
}
emit();