Reputation: 79
I found I can use Google Analytics Debugger Chrome extension to find GA JavaScript running, like this:
ga("create", "UA-43334570-1", "betfair.com")
From chrome developer tools, I can see many XHR requests come with cookies like: _gcl_au=1.1.798104834.1582236339; _ga=GA1.2.1976707491.1582236339; _gid=GA1.2.1017527267.1582236339; However, my goal is to use C# HTTP client to post some data to this web site. I can't run JavaScript in my C# code, so I want to know if there is any .NET/C# equivalent package, than I can generate the above Google Analytics cookies and add them to cookie container, then post data to the web server.
Let me know if it is possible or any other better idea on how to find those cookies without study all the lengthy JavaScript on the web site.
I have tried this: I clear all the cookies from Chrome, and visit the web site, I inspected all the network requests, I can't see any HTTP response request set-cookies with any of those Google Analytics cookie values, but suddenly some network requests come with such cookies.
However, I can see one request did get this JavaScript file: "https://www.google-analytics.com/analytics.js"
But I can't figure out how this analytics.js is being used by the web site: www.betfair.com.
Why those GA cookies suddenly appear in the XHR requests?
Please advice.
Thanks,
Upvotes: 0
Views: 1168
Reputation: 13334
The main GA cookie _ga
is generated client-side by JavaScript, hence why you don't see it in the set-cookie
HTTP header:
https://developers.google.com/analytics/devguides/collection/analyticsjs/cookies-user-id
The analytics.js library accomplishes this via the Client ID field, a unique, randomly generated string that gets stored in the browsers cookies, so subsequent visits to the same site can be associated with the same user
If you look at https://www.google-analytics.com/analytics.js you'll indeed with code setting some cookies:
Thus GA cookies are first-party cookies (JS can't create/read cookies for domains other than the one you're browsing + its top/subdomains for obvious security reasons), hence why you see those GA cookies attached to requests on the browsed domain.
Upvotes: 2