Skip to main content
POST
/
trackPageView
Track a page view
curl --request POST \
  --url https://js.hs-scripts.com/trackPageView \
  --header 'Content-Type: application/javascript' \
  --data @- <<EOF
"_hsq.push(['trackPageView']);"
EOF
Manually track a page view. This is automatically called when the tracking code loads, but can be used for single-page applications.
trackPageView is automatically called when the tracking code loads, so you should not push any trackPageView calls to _hsq before the page loads.

Usage

Basic Page View

var _hsq = (window._hsq = window._hsq || []);
_hsq.push(["trackPageView"]);

For Single-Page Applications

var _hsq = (window._hsq = window._hsq || []);
// First set the path
_hsq.push(["setPath", "/about-us"]);
// Then track the page view
_hsq.push(["trackPageView"]);

Notes

  • Use this method when you need to track page views without reloading the page
  • Commonly used in single-page applications (SPAs)
  • Use with setPath to track the correct page path in SPAs

Body

application/javascript

Page view tracking data

path
string

Optional path to track (if different from current page)

Response

200

Page view tracked successfully