26

Perhaps I am missing something, but I am just learning javascript.

My understanding of Single Origin Policy is that Google Analytics should not be able to send data back to Google.

How is it able to transmit send data to Google without violating the policy?

asked Jan 5, 2009 at 20:45
1
  • Good question, never released to look into this sort of question. Commented Apr 7, 2011 at 5:38

2 Answers 2

33

From what I can tell, a webpage includes the JavaScript file from Google, then that script dynamically adds an image to the page (http://www.google-analytics.com/__utm.gif) which contains the information required for logging.

SOP does not apply to scripts, images or CSS files that are dynamically added to a page. This is why you much trust whatever JavaScript files you include in your webpages, as they will have complete control over the page.

answered Jan 5, 2009 at 20:59
Sign up to request clarification or add additional context in comments.

7 Comments

Where does it get the image? If it gets it from Google, doesn't this violate the policy?
The image is from google-analytics.com. Again, the SOP only applies to XHR requests, not files that are included in a page (JS, images & CSS).
Important to note that it doesn't add the image to the page; it just requests the image in JavaScript by doing something like var img = new Image(); img.src="http://google-analytics/__utm.gif?...
Why a gif and not just a png image?
@Dofs It doesn't matter what type of image or asset being loaded. The point is the data being sent to Google is important. What is returned is irrelevant.
|
5

Ryan Doherty is correct. The Google Analytics javascript code draws a transparent 1px-by-1px gif image name __utm.gif on your page. When the request (which is located on Google's servers) for this image is made, information is appended as GET parameters. Google captures this data and begins processing it. Usually within 3-6 hours, you'll see the data show up in your GA reports.

answered Feb 16, 2009 at 19:32

2 Comments

does you mean to say. That gif holds the data.
@user254153 No, it is the request (for the image) holds the data, you can refer to Google's page which explain their mechanism in details: developers.google.com/analytics/resources/concepts/…

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.