By default, the New RUM Experience captures a request event whenever the application sends an XMLHttpRequest (XHR) or Fetch request. If a click user interaction triggers the request, a request user action is also captured. You can exclude both request and user action events by creating XHR exclusion rules. These rules are especially useful when your application sends frequent status-based XHR calls that you don't want to include in your user data.
To exclude XHR and Fetch requests from monitoring
Experience Vitals > Overview.Inefficient regular expressions can cause performance issues in your application, including browser freezes lasting several seconds. For better performance, write expressions that match a URL substring rather than the entire URL. This is especially relevant for long URLs.
The RUM JavaScript tests the regular expression against the URL using RegExp.prototype.test(). The regular expression does not need to match the full URL, but only a substring of it. Matching is case-insensitive.
In the New RUM Experience, the matched URL is always an absolute URL. In RUM Classic, the URL is whatever was passed to the XHR or Fetch call, which can be either relative or absolute. XHR exclusion rules that you configure in the New RUM Experience also apply in RUM Classic, so if you want a rule to work for both, write a regular expression that matches both the absolute URL and the URL passed to the XHR or Fetch call.
When composing your regular expression using a site like Regex101, select ECMAScript (JavaScript) as the flavor and turn on the Case insensitive match flag.
The following examples show how to specify XHR exclusion rules for common scenarios.
An application sends heartbeat requests using XMLHttpRequest, and since these are same-origin requests, it uses the relative URL /api/heartbeat. Therefore, RUM Classic matches XHR exclusion rules against /api/heartbeat, while the New RUM Experience matches them against the absolute URL https://example.com/api/heartbeat.
Specifying an XHR exclusion rule with the regular expression /api/heartbeat excludes the heartbeat requests from monitoring in both the New RUM Experience and RUM Classic.
An application uses Google Analytics, which sends beacons with the URL https://www.google-analytics.com/g/collect?v=2&tid=G-XXXXXXXX&.... Since these are cross-origin requests and the absolute URL is used for the call, XHR exclusion rules match against the absolute URL in both the New RUM Experience and RUM Classic.
Specifying an XHR exclusion rule with the regular expression google-analytics\.com/g/collect excludes these requests from monitoring in both the New RUM Experience and RUM Classic.
An application uses Google Analytics, which sends requests to the following URLs:
https://www.google-analytics.com/g/collect?v=2&tid=G-XXXXXXXX&...https://region1.google-analytics.com/g/collect?v=2&tid=G-XXXXXXXX&...https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXhttps://www.googletagmanager.com/gtm.js?id=GTM-XXXXXXXhttps://www.google-analytics.com/collect?v=1&tid=UA-XXXXXXXX-1&...Since these are cross-origin requests and the absolute URL is used for the call, XHR exclusion rules match against the absolute URL in both the New RUM Experience and RUM Classic.
Specifying an XHR exclusion rule with the regular expression google-analytics\.com|googletagmanager\.com excludes these requests from monitoring in both the New RUM Experience and RUM Classic.