Set Page Path

Last updated October 21, 2021

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

Update the path of the current page stored in the tracker. 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'll need to call the trackPageView function to track the view of the current page.

This function will only update the path of the URL. The domain is set automatically based on the URL of the page load. The path will always be relative to the detected domain.

Notes:
  • Repeated use of setPath will override the referrer, which can impact a contact's original source, depending on when a tracking request is made. 
  • 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.

 

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