html - JavaScript: reduce Google Analytics / Yandex.Metrica to referrer and screen size -
i don't feel comfortable embedding external javascript on site kinds of tracking don't need.
what need referrer , screen size, cannot accomplished static html img
tag alone.
what's standard-compliant, browser-supported , rendering-friendly way load invisible image, 1×1 gif, referrer , screen size part of url?
i'm looking generic answer, although phrase in terms of google analytics gif request parameters.
document.referrer
referrer.
window.screen.width
, window.screen.height
screen resolution.
you can use these new image()
have browser request tracking pixel. use encodeuricomponent
sanitize values before appending them url.
var r = encodeuricomponent(document.referrer), x = window.screen.width, y = window.screen.height, img = new image(); img.src = '/tracking.gif?x=' + x + '&y=' + y + '&r=' + r;
note on subsequent requests, cached, won't count of pageviews (although didn't wanted this). desirable behavior since you'd implicit unique visitor tracking. circumvent caching, however, add current timestamp via new date().gettime();
additional parameter.
Comments
Post a Comment