BackstopJS icon indicating copy to clipboard operation
BackstopJS copied to clipboard

Stop tests from triggering google analytics

Open bjornlauwerijs opened this issue 3 years ago • 1 comments

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());

bjornlauwerijs avatar Oct 18 '22 21:10 bjornlauwerijs

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);
};

fuhlig avatar Feb 15 '23 16:02 fuhlig