Lead Gen & CRM
How can we help you?
Search our help articles, video tutorials, and quickstart guides

You've got this. You've got us. Search our Knowledge Base to quickly find answers to your questions.

Tracking Single-Page Applications

Article: 000050360
Updated: July 18, 2024

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.


Article Contents


Users:
Administrators 
Company Managers  
Marketing Managers  
Sales Managers  
Salespersons  
Jr. Salespersons  

Light Bulb IconTip: 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.

 

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:

  1. Click  12personas.png  User Menu > Settings in SharpSpring's top toolbar.
  2. Click Sites, located under Tracking in the left panel.
  3. Add tracking code to your website.
  4. Paste the following code snippet below the tracking code: 
 
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. 

 


Did this article answer your question?


Constant Contact Logo

Copyright © 2025 · All Rights Reserved · Constant Contact · Privacy Center