I found a pretty simple way to do it for Chrome and Firefox using the Google Analytics Opt out Add ons, which are maintained for basically all browser. Refering to this SO question about browser plugin testing with selenium, I was able to open a GA/free selenium session with the following code for C#
var options = new ChromeOptions(); options.Proxy = proxy; options.AddExtension(Path.GetFullPath("chrome-ga-optout-extension.crx")); var driver = new ChromeDriver(options);
var profile = new FirefoxProfile(); profile.AddExtension(Path.GetFullPath("firefox-ga-optou-addon.xpi")); profile.SetProxyPreferences(proxy); var driver = new FirefoxDriver(profile);
Unfortunately with this approach for IE, we are at the mercy of Selenium implementing add on support for IE Driver, which is probably a hopeless case…. If anyone can think of a solution for IE, that would be amazing.