Search code examples
javascriptcookiesgoogle-analyticscross-domainanalytics

how does google analytics know to load overlay on own domain after logging to google.com/analytics?


I noticed that after you log into google.com/analytics, and see 'in page' feature, after you enter your own domain, you see the same report.

How do they know? as there are different domains. The cookie solution is not a choice as the logging in is done on google.com and the overlay is shown on own domain. There is absolutely no logging in on own domain.

Does the javascript on my domain set a cookie?

Thanks


Solution

  • I just checked and for me it loaded it in an iframe

    Edit

    Ok got it to load in the whole site, looks like it adds in a bunch of stuff on the url hash

    example.com/page#gaso=pNl50_ygxyusFT6rXNNxTiQk2j7Qorb_ygw6EbrhHRD4Z8eX12C8tn5DaTqIoevkeUiDDSP4aLsYc9.sRMQO9II5Ii_zuKJ7un2DQ

    Looks like they use CrossDomainChannel so the cross origin iframes can talk. "A communication channel between two documents from different domains."

    http://closure-library.googlecode.com/svn/!svn/bc/4/trunk/closure/goog/docs/closure_goog_net_xpc_crosspagechannel.js.source.html

    I used something similar - here is a jQuery version in case you're interested

    http://benalman.com/projects/jquery-postmessage-plugin/