---
title: Browser/SPA NRQL query examples
source: https://docs.newrelic.com/docs/nrql/nrql-examples/browserspa-nrql-query-examples
---

This document will explain how you can use [NRQL](https://docs.newrelic.com/docs/query-data/nrql-new-relic-query-language/getting-started/introduction-nrql) to query and explore your [Browser](https://docs.newrelic.com/docs/browser/new-relic-browser/getting-started/introduction-new-relic-browser) data, including [SPA](https://docs.newrelic.com/docs/browser/single-page-app-monitoring/get-started/welcome-single-page-app-monitoring) data.

## View JavaScript errors [#javascriptError-example]

To view [JavaScript errors](https://docs.newrelic.com/docs/browser/new-relic-browser/browser-pro-features/javascript-errors-page-examine-errors-over-time), you'd run a [NRQL query](https://docs.newrelic.com/docs/query-data/nrql-new-relic-query-language/getting-started/introduction-nrql) of the [`JavaScriptError` event](https://docs.newrelic.com/docs/insights/insights-data-sources/default-data/browser-default-events-attributes-insights#javascriptError-attributes) reported by Browser. For example:

```sql
SELECT * FROM JavaScriptError
```

Here's an example `JavaScriptError` event record with sample attributes:

```json
{
  "agentVersion": "1.322.0",
  "appId": 1234567,
  "appName": "Book Staging Multiverse",
  "asn": "12345",
  "asnLatitude": 37.3861,
  "asnLongitude": -122.0839,
  "asnOrganization": "EXAMPLE-ISP",
  "browserInteractionId": "abc123def456ghi789",
  "browserStackHash": 1234567890,
  "city": "Example City",
  "countryCode": "US",
  "deviceType": "Desktop",
  "domain": "example.com",
  "entityGuid": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "errorClass": "Error",
  "errorMessage": "Script error message",
  "firstErrorInSession": true,
  "firstOccurrenceTimestamp": 1234567890000,
  "pageUrl": "https://example.com/example-page",
  "regionCode": "CA",
  "releaseIds": "{\"jQuery\":\"v3.1.1\",\"app\":\"1a2b3c4\"}",
  "requestUri": "/synthetic-multiverse/",
  "session": "abc123def456ghi789",
  "sessionTraceId": "abc123def456ghi789",
  "stackHash": 987654321,
  "stackTrace": "Error: Script error message.\n    at anonymous:1:1",
  "timestamp": 1234567890,
  "transactionName": "Unnamed Transaction",
  "userAgentName": "Chrome",
  "userAgentOS": "Linux",
  "userAgentVersion": "44"
}
```

## View sample SPA data [#explore-spa-data]

To run a [NRQL query](https://docs.newrelic.com/docs/query-data/nrql-new-relic-query-language/getting-started/introduction-nrql) of your Browser [SPA data](https://docs.newrelic.com/docs/browser/single-page-app-monitoring/get-started/introduction-single-page-app-monitoring), use the `BrowserInteraction` or `AjaxRequest` events. For example:

```sql
SELECT * FROM BrowserInteraction
```

Here are some examples of NRQL queries you can make of your SPA data. To see all Browser attributes, see [Browser default attributes](https://docs.newrelic.com/docs/insights/insights-data-sources/default-data/browser-default-events-attributes-insights).

**Count route changes and page loads**

To count the route changes and page loads in the past day:

````sql
SELECT count(*) FROM BrowserInteraction
SINCE 1 day ago
```

````

**Average duration of route changes and page loads**

To find the average duration of route changes and page loads in the past day:

````sql
SELECT average(duration) FROM BrowserInteraction 
SINCE 1 day ago
```

````

**Slowest route changes**

To find the 10 slowest route changes in the past day:

````sql
SELECT average(duration) FROM BrowserInteraction 
WHERE category = 'Route change' 
SINCE 1 day ago FACET browserInteractionName
```

````

**Most popular route changes**

To find the ten most popular route changes in the last day:

````sql
SELECT count(*) FROM BrowserInteraction 
WHERE category = 'Route change' 
SINCE 1 day ago FACET browserInteractionName
```

````

**Compare page load and route change throughput**

To compare the throughput between page loads and route changes in the last day, at 1-hour increments:

````sql
SELECT count(*) FROM BrowserInteraction SINCE 1 day ago FACET category TIMESERIES 1 hour
```

````

**Compare page load and route change performance**

To compare the performance of page loads and route changes in the last day, at 1-hour increments:

````sql
SELECT average(duration) FROM BrowserInteraction 
SINCE 1 day ago FACET category TIMESERIES 1 hour
```

````

**Create table using certain criteria**

To create a data table of the average, minimum, and maximum Ajax counts for the 20 slowest route changes:

````sql
SELECT average(duration), average(ajaxCount), min(ajaxCount), max(ajaxCount) 
FROM BrowserInteraction WHERE category = 'Route change' SINCE 1 day ago 
FACET browserInteractionName LIMIT 20
```

````
