A single-page application (SPA) is a web application or web site that fits on a single web page with the goal of providing a more fluid user experience akin to a desktop application. In order to track events for single-page websites, your webpage must use URLs that use the hashtag appended to the URL. This article will detail how to track single-page applications.
|
Available with: | ||||
Marketing Automation | ✓ | ||||
CRM Ultimate | |||||
CRM PRO | |||||
CRM Free | |||||
Toolbar: | |||||
![]() |
|||||
Users: | |||||
Administrators | ✓ | ||||
Company Managers | |||||
Marketing Managers | |||||
Sales Managers | |||||
Salespersons | |||||
Jr. Salespersons | |||||
Adding Code
If you are looking to track events on a single page, your website must use tracking code. To add tracking code, do the following: |
Note: SharpSpring offers Professional Services to assist with custom coding.
|
- Add tracking code to your website.
- Paste the following code snippet below the tracking code:
<!-- TRACKING CODE GOES HERE --> <!-- Script Example of Catching URL hash changes --> <script type='text/javascript'> if ("onhashchange" in window) { window.onhashchange = function () { _ss.push(['_trackPageView']); } } else { var prevHash = window.location.hash; window.setInterval(function () { if (window.location.hash != prevHash) { prevHash = window.location.hash; _ss.push(['_trackPageView']); } }, 100); } </script>
This will run_ss.push(['_trackPageView'])
when the URL hash changes, which will track a new page view.