Stop tests from triggering google analytics
bjornlauwerijs opened this issue · 1 comments
bjornlauwerijs commented
Tried searching for a way to stop triggering google analytics on every scenario that gets run () having three different viewports also triggers a visitor for each test). This is probably an easy thing to do, but not really succeeding in this.
I sadly do not have any way to exclude my local machine from the google analytics.
I tried adding following in playwright/onBefore.js but this is unsuccessful. Any tips?
browserContext.route('*.google-analytics.com', request => request.abort());
fuhlig commented
I am setting a custom userAgent which is excluded within analytics
e.g.
// onBefore scripts
module.exports = async (page) => {
// Set user agent to identify test and ignore in analytics
await page.setUserAgent('test/Crawler_Exclude/visual-regression-testing);
};