Suppose I search for a website Website1 on google. When I click on a search result link, it takes me first to a google server URL and then redirects me to the actual site i.e. Website1.
From this I understand, that before redirecting to the actual website, google stores information like keyword used for search, etc in cookies for the website domain (which I am searching i.e. Website1) using cookies. Then, when the actual website loads, the analytics script extracts this information from the cookies and pushes it to Google Analytics server.
My question here is how can google store cookies on behalf of the other site. As per my understanding, first party cookies can be created and accessed by the domain itself.
Just to confirm if cookies can be set for other domains, I searched and found links similar to this.
Any pointers please?