How does Google set the first analytics tracking cookies?

Suppose I am looking for Website1 at Google. When I click on the link to the search result, it takes me first to the google server url and then redirects me to the actual site, i.e. Website1 .

From this I understand that before being redirected to the actual website google stores information such as the keyword used for search, etc. in cookies for the website domain (which I am looking for, for example, Website1 ) using cookies. Then, when the actual site loads, the analytics script extracts this information from the cookies and pushes it to the Google Analytics server.

My question here is how Google Cookies can store cookies on behalf of another site. In my understanding, first-party cookies can be created and accessible to the domain itself.

To confirm whether cookies can be set for other domains, I searched and found links similar to.

Any pointers please?

+4
source share
1 answer

You misunderstood the mechanism - the Google Analytics script receives keywords, etc. from the link URL (the click URL on the search results page contains a lot of information, like the keyword and the position of the search result in serp).

The analytics script extracts information from the referrer and (besides sending it to google) stores it in a cookie (in fact, the new universal analytics does not do this anymore). But this happens in your own domain.

Google Analytics can set cookies for your domain, because by inserting their javascript code on your website, you basically gave them the city key - Google can write and read cookies, they can - and do - load other scripts, they can steal sessions, deactivate your site, etc. Not that Google has ever done this, but if you go beyond world domination, you should start by hacking into servers that supply javascript code for analytics.

However, Google cannot set the first cookie from the google domain, and they do not need it. All this at the reference address.

+2
source

Source: https://habr.com/ru/post/1502166/


All Articles