<p>I want to capture the HTTP request header fields, primarily the Referer and User-Agent, within my client-side JavaScript.  How may I access them?</p>

<hr>

<p>Google Analytics manages to get the data via JavaScript that they have you embed in you pages, so it is definitely possible.</p>

<blockquote>
  <p><strong>Related:</strong><br>
  <a href="https://stackoverflow.com/questions/220231/accessing-http-headers-in-javascript">Accessing the web page&#39;s HTTP Headers in JavaScript</a></p>
</blockquote>

If you want to access referrer and user-agent, those are available to client-side Javascript, but not by accessing the headers directly.
To retrieve the referrer, use
```
document.referrer
```
.
To access the user-agent, use
```
navigator.userAgent
```
.
As others have indicated, the HTTP headers are not available, but you specifically asked about the referer and user-agent, which are available via Javascript.