var ref = document.referrer; var url = window.location.href; var country = google.loader.ClientLocation.address.country; var country_code = google.loader.ClientLocation.address.country_code; var region = google.loader.ClientLocation.address.region; var city = google.loader.ClientLocation.address.city; var screenX = document.viewport.getWidth(); var screenY = document.viewport.getHeight(); var statistic_id = ''; var post = "ref=" + ref + "&country=" + country + "&country_code=" + country_code + "®ion=" + region + "&city=" + city + "&url=" + url + "&screenx=" + screenX + "&screeny=" + screenY; new Ajax.Request('/shop/statistic', {postBody: post, onComplete: function(r){ statistic_id = r.responseText; }}); $$('a[href]').invoke("observe","click", function(e) { var post = "statistic_id=" + statistic_id + "&href=" + encodeURIComponent(e.element().href) + "&x=" + e.pointerX() + "&y=" + e.pointerY(); e.stop(); new Ajax.Request('/shop/statistic', {postBody: post, onComplete: function(){ if (e.element().href==undefined) window.location.href = e.element().up('a').href; else window.location.href = e.element().href; }}); });