Set Page Path

_hsq.push(['setPath', { path string }])

Update the path of the current page.  This function should be used by single-page applications to update the current page whenever a page is loaded.  After using this function to update the path, you will need to call the trackPageView function to track the view of the current page.

  • This function call only updates the path stored in the tracker. You'll need to call the trackPageView function to actually track the updated page.
  • Single-page applications should push a setPath call into _hsq before the tracking code loads to set the URL that gets tracked for the first page view (the trackPageView function is called automatically when the tracking code is loaded). See the Tracking Code overview page for an example of this.
  • This function can only update the path of the URL.  The domain is set automatically based on the URL of the page on load, and the path that is set using this function is always treated as relative to that detected domain.


Required Parameters How to use Description
Path 'setPath', { path string } The path of the current page. The set path will be treated as realtive to the current domain being viewed. The path should always start with a preceding slash. See the examples for more details.