I want to track some sites using PhantomJS, but I don’t want to spam peoples Google Analytics. Is there a way to disable the Google Analytics tracking script (ga.js / analytics.js) from sending data to Google? Like it is possible with the usual GAOptOut browser plugins.
I had a look in the Chrome Plugin and tried the code from that, but it doesn’t seem to be executed when telling PhantomJS to do so (onLoadStart).
To control who uses Analytics in your organization Sign in using your administrator account (does not end in @gmail.com). Google Analytics. Click Service status. To turn on or off a service for everyone in your organization, click On for everyone or Off for everyone, and then click Save.
Websites can still track what pages you visit on their site though by using server logs. Secondly, preventing Google from having information on websites you visit is a large reason to start opting out of Google Analytics.
Google uses personal data from Google Analytics, Global Site Tag, and from their many other trackers and products, so they can target you with advertising and content they think you'll want to see.
Use page.onResourceRequested
method to abort all requests to google analytics.
page.onResourceRequested = function(requestData, request) {
if ((/google-analytics\.com/gi).test(requestData['url'])){
console.log('Request to GA. Aborting: ' + requestData['url']);
request.abort();
}
};
Related, full example: https://github.com/ariya/phantomjs/blob/master/examples/loadurlwithoutcss.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With