> ## Documentation Index
> Fetch the complete documentation index at: https://developers.hubspot.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

---
id: 50dced9b-349f-46e7-8796-44cd5e948dc6
---

# Set the current page path

Set the path for tracking in single-page applications. Use before calling `trackPageView` to track the correct page.

## Usage

```javascript theme={null}
var _hsq = (window._hsq = window._hsq || []);
_hsq.push(["setPath", "/about-us"]);
```

## Single-Page Application Example

```html theme={null}
<!-- Set up the path for the initial page view -->
<script>
  var _hsq = window._hsq = window._hsq || [];
  _hsq.push(['setPath', '/home']);
</script>

<!-- Load the HubSpot tracking code -->
<!-- Start of HubSpot Embed Code -->
  <script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/{hubId}.js"></script>
<!-- End of HubSpot Embed Code -->

<!-- Tracking subsequent page views -->
<script>
  var _hsq = window._hsq = window._hsq || [];
  _hsq.push(['setPath', '/about-us']);
  _hsq.push(['trackPageView']);
</script>
```

## Notes

* Essential for tracking page views in single-page applications.
* Always call `setPath` before `trackPageView` to ensure accurate tracking.
* The path should start with a forward slash (`/`).
