Filter Automate sessions from Google Analytics
You can exclude the requests that remote browsers send to your site from Google Analytics.
Introduction
As you test public websites on BrowserStack, the remote browsers request your website to run your tests. These requests count towards your pageviews/sessions in Google Analytics (or similar tools).
Currently, you cannot block/exclude Google Analytics script from loading on remote browsers.
Instead, you can use --force-local
parameter in Local Testing (to route traffic to remote browsers through your machine) and then exclude traffic from your machine IP from Google Analytics. This article shows you how.
Set up local connection on your machine
Follow the steps below to set up Local Testing on your machine:
Step 1: Download the appropriate binary:
The download links are secure. The binaries are digitally signed, identifying the publisher as ‘BrowserStack Ltd.’
Step 2: Navigate to the folder containing the Local Binary.
Step 3: Use the following command to run it from the command-line interface:
./BrowserStackLocal --key YOUR_ACCESS_KEY --force-local
BrowserStackLocal.exe --key YOUR_ACCESS_KEY --force-local
Note: The --force-local
parameter routes all traffic to remote browsers through your machine.
Step 4: Once the local connection is established, you can configure your tests so they can run through the connection. To do this, add the following snippet to your test scripts:
caps.setCapability("browserstack.local", "true");
caps['browserstack.local'] = 'true'
desiredCap.SetCapability("browserstack.local", "true");
desired_cap['browserstack.local'] = True
capabilities['browserstack.local'] = true;
Exclude your machine / network IPs from Google Analytics
Once you have set up local connection and configured your tests, you’ll need to exclude requests to your website from your machine / network IPs from Google Analytics.
Now, all Automate sessions you run through this setup will be excluded from Google Analytics.
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!