---
title: Add browser monitoring to your Go apps
source: https://docs.newrelic.com/docs/apm/agents/go-agent/features/add-browser-monitoring-your-go-apps
---

If you installed New Relic's Go agent for your app, you can also use [browser monitoring](https://docs.newrelic.com/docs/browser/new-relic-browser/getting-started/introduction-new-relic-browser) to monitor browser performance. To install the browser agent, use the [copy and paste method](https://docs.newrelic.com/docs/browser/new-relic-browser/installation/install-new-relic-browser-agent#copy-paste-app), or use the Go agent API.

## Install with Go agent browser API [#go-browser-api]

To enable support for browser monitoring, your HTML pages must include a JavaScript snippet that will load the browser agent and configure it with the correct application name. This snippet is available with the `Transaction.BrowserTimingHeader` method. Support for browser monitoring's timing headers is available with [Go agent versions 2.5.0 or higher](https://docs.newrelic.com/docs/release-notes/agent-release-notes/go-release-notes).

Include the byte slice returned by `Transaction.BrowserTimingHeader().WithTags()` as early as possible in the `<head>` section of your HTML and after any `<meta charset>` tags.

The JavaScript returned from `Transaction.BrowserTimingHeader` is request-specific. That's why it must be called on each request.

```go
func indexHandler(w http.ResponseWriter, req *http.Request) {
    io.WriteString(w, "<html><head>")

    // The New Relic browser javascript should be placed as high in the
    // HTML as possible. We suggest including it immediately after the
    // opening <head> tag and any <meta charset> tags.
    txn := newrelic.FromContext(req.Context())
    hdr := txn.BrowserTimingHeader()
    // BrowserTimingHeader() will always return a header whose methods can
    // be safely called.
    if js := hdr.WithTags(); js != nil {
        w.Write(js)
    }
    
    io.WriteString(w, "</head><body>browser header page</body></html>")
}
```
