Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, i disagree with the two previous answers--neither engages the question. </p> <p>The one-pixel image solves an intrinsic problem for web-based analytics apps (like Google Analytics) when working in the HTTP Protocol--<strong><em>how to transfer (web metrics) data from the client to the server</em></strong>.</p> <p>The simplest of the methods described by the Protocol, the simplest (at lest the simplest method that includes a request body) is the <strong>GET request</strong>. According to this Protocol method, clients initiate requests to servers for resources; servers process those requests and return appropriate responses.</p> <p>For a web-based analytics app, like GA, this uni-directional scheme is bad news, because it doesn't appear to allow a server to retrieve data from a client on demand--again, all servers can do is supply resources not request them.</p> <p><em>So what's the solution to the problem of getting data from the client back to the server?</em> Within the HTTP context there are other Protocol methods other than GET (e.g., POST) but that's a limited option for many reasons (as evidenced by its infrequent and specialized use such as submitting form data).</p> <p>If you look at a GET Request from a browser, you'll see it is comprised of a Request URL and <strong><em>Request Headers</em></strong> (e.g., Referer and User-Agent Headers), the latter contains information about the client--e.g., browser type and version, browser langauge, operating system, etc.</p> <p>Again, this is part of the Request that the client sends to the server. So <strong><em>the idea that motivates the one-pixel gif is for the client to send the web metrics data to the server, wrapped inside a Request Header.</em></strong></p> <p>But then <em>how to get the client to Request a resource so it can be "tricked" into sending the metrics data?</em> And how to get the client to send the actual data the server wants?</p> <p>Google Analytics is a good example: the <em>ga.js</em> file (the large file whose download to the client is triggered by a small script in the web page) includes a few lines of code that <em>directs the client to request a particular resource from a particular server (the GA server) and to send certain data wrapped in the Request Header.</em></p> <p>But since the purpose of this Request is not to actually get a resource but to send data to the server, this resource should be a small as possible and it should not be visible when rendered in the web page--hence, the 1 x 1 pixel transparent gif. The size is the smallest size possible, and the format (gif) is the smallest among the image formats.</p> <p>More precisely, all GA data--every single item--is assembled and packed into the <strong><em>Request URL's query string</em></strong> (everything after the '?'). But in order for that data to go from the client (where it is created) to the GA server (where it is logged and aggregated) there must be an HTTP Request, so the ga.js (google analytics script that's downloaded, unless it's cached, by the client, as a result of a function called when the page loads) directs the client to assemble all of the analytics data--e.g., cookies, location bar, request headers, etc.--concatenate it into a single string and append it as a query string to a URL (<strong>*http://www.google-analytics.com/__utm.gif*</strong>?) and that becomes the <em>Request URL</em>. </p> <p>It's easy to prove this using any web browser that has allows you to view the HTTP Request for the web page displayed in your browser (e.g., Safari's <em>Web Inspector</em>, Firefox/Chrome <em>Firebug</em>, etc.).</p> <p>For instance, i typed in valid url to a corporate home page into my browser's location bar, which returned that home page and displayed it in my browser (i could have chosen any web site/page that uses one of the major analytics apps, GA, Omniture, Coremetrics, etc.)</p> <p>The browser i used was Safari, so i clicked <em>Develop</em> in the menu bar then <em>Show Web Inspector</em>. On the top row of the Web Inspector, click <em>Resources</em>, find and click the utm.gif resource from the list of resources shown on the left-hand column, then click the <em>Headers</em> tab. That will show you something like this:</p> <pre><code>Request URL:http://www.google-analytics.com/__utm.gif? utmwv=1&amp;utmn=1520570865&amp; utmcs=UTF-8&amp; utmsr=1280x800&amp; utmsc=24-bit&amp; utmul=enus&amp; utmje=1&amp; utmfl=10.3%20r181&amp; Request Method:GET Status Code:200 OK Request Headers User-Agent:Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1 Response Headers Cache-Control:private, no-cache, no-cache=Set-Cookie, proxy-revalidate Content-Length:35 Content-Type:image/gif Date:Wed, 06 Jul 2011 21:31:28 GMT </code></pre> <p>The key points to notice are:</p> <ol> <li><p>The Request was in fact a request for the utm.gif, as evidenced by the first line above: *Request URL:http://www.google-analytics.com/__utm.gif*.</p></li> <li><p><em>The Google Analytics parameters are clearly visible in the query string appended to the Request URL</em>: e.g., <em>utmsr</em> is GA's variable name to refer to the client screen resolution, for me, shows a value of 1280x800; <em>utmfl</em> is the variable name for flash version, which has a value of 10.3, etc.</p></li> <li><p>The <em>Response Header</em> called <em>Content-Type</em> (sent by the server back to the client) also confirms that the resource requested and returned was a 1x1 pixel gif: <strong><em>Content-Type:image/gif</em></strong></p></li> </ol> <p>This general scheme for transferring data between a client and a server has been around forever; there could very well be a better way of doing this, but it's the only way i know of (that satisfies the constraints imposed by a hosted analytics service).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload