var script = document.createElement('script'); script.src = 'https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.4.5/socket.io.min.js'; script.onload = function () { //do stuff with the script }; document.head.appendChild(script); waitForElement(); function waitForElement(){ if(typeof io !== "undefined"){ Function_Loaded() } else{ setTimeout(waitForElement, 250); } } function Function_Loaded(){ var socket = io('https://js.ogstats.com/'); socket.on('connect', function(){ var sessionid = socket.io.engine.id; var visitorData = { sessionid: sessionid, zone: _webzone, ip: "2601:240:ca01:9723:2895:2c16:d63c:b23c", isp: "Comcast Cable", connectiontype: "Cable/DSL", countrycode: "US", state: "Illinois", city: "Chicago", postalcode: "60610", latitude: "41.8998", longitude: "-87.6368", referringsite: document.referrer, page: window.location.href, useragent: navigator.userAgent, device: "Spider", browser: "CCBot", browserversion: "2.0", os: "Other", osversion: "" } var visitorData = JSON.stringify(visitorData); socket.emit('visitor-data', visitorData); }); } console.log('Web analytics provided by... www.ogstats.com'); console.log('The best FREE analytics tool for internet marketers.');