A single-page application (SPA) is a web application or website 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.
| Administrators | ✓ | |
| Company Managers | ||
| Marketing Managers | ||
| Sales Managers | ||
| Salespersons | ||
| Jr. Salespersons |
| Tip: Are you looking for information about Constant Contact’s Email and Digital Marketing product? This article is for Constant Contact’s Lead Gen & CRM product. Head on over to the Email and Digital Marketing articles by clicking here. Not sure what the difference is? Read this article. |
|
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.
|
<!-- 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.
Copyright © 2025 · All Rights Reserved · Constant Contact · Privacy Center