---
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 of JSON resulting from running this query, which includes `JavaScriptError` attributes.

```json
"event": {
  "deviceType": "Desktop",
  "firstErrorInSession": true,
  "releaseIds": "{\"jQuery\":\"v3.1.1\",\"multiverse\":\"98e7ab6\"}",
  "appName": "Book Staging Multiverse",
  "errorClass": "Error",
  "errorMessage": "Script error message",
  "requestUri": "/synthetic-multiverse/",
  "userAgentName": "Chrome",
  "transactionName": "Unnamed Transaction",
  "userAgentVersion": "44",
  "appId": 950582,
  "userAgentOS": "Linux",
  "timestamp": 1502262005,
  "browserInteractionID": ,
  "parentEventId": 
}
```

## 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
```

````
