What is an SPA?
“A single-page application (SPA) is a web application or website that interacts with the user by dynamically rewriting the current web page with new data from the web server, instead of the default method of a web browser loading entire new pages.” - Wikipedia
In simpler terms, an SPA is a type of application or a “website” that does not need a page to be reloaded in order to show new content. SPAs are capable of dynamically changing the content, so they don’t need to reload the pages.
What is SPA tracking?
Currently, the Leadfeeder script does not track the changes of page URL. It only considers a new pageview when the page is reloaded.
Since SPAs don’t necessarily reload pages, it leads to lack of insights for our users. Leadfeeder would show only a single pageview in such cases, instead of all the pages the user viewed during their visit.
To improve this behaviour, EPIC has added a new “tracking mode” in the Leadfeeder script. We call it the “SPA” tracking mode.
Which SPAs are eligible for this mode?
Many SPAs change the page URL while updating the content without reloading the page. Leadfeeder script now supports tracking of pageviews for such SPAs.
Some SPAs don’t change the page URLs while updating the content. Such SPAs are not eligible for our SPA tracking, and they might have to rely on manual tracking
Essentially, SPA tracking mode only records changes in the page URL, without reload. If the page URL doesn’t change when a specific action is performed, it won’t be tracked.
How does it work?
When SPA tracking is enabled, Leadfeeder tracker will start identifying changes in the page URLs even if the page is not reloaded.
For tracking changes in the same page URL, the changes need to be at least 1 second apart. We do this so we don’t generate unnecessary pageviews in cases of rage clicks or repetitive clicks by visitors.
For example, if a button that changes the page URL is clicked multiple times, the changes in pageviews will be recorded only for clicks that were at least 1 second apart.
For example,
3 clicks done in < 1 second would record 1 pageview.
2 clicks done in < 1 second and 1 click done after 1 second would record 2 pageviews.
The tracker currently identifies two types of changes in the page URL
Changes in URL path
For example, while on www.example.com/product if a button is clicked, the URL changes to www.example.com/contact without reloading the page
https://example.org/home changes to https://example.org/new?date=today and then changes to https://example.org/contact?param without reloading the page
Changes in the URL hash fragment (part of the URL after #)
For example, while on www.example.com/product if a button is clicked, the URL changes to www.example.com/product#contact
while on www.example.com/product#info if a button is clicked, the URL changes to www.example.com/product#contact
In this example, the hash fragments are #info and #contact
What does it imply for users?
When SPA tracking is enabled, each change in the URL will create a new page view. If the page URLs change very frequently, the pageviews in a visit are expected to go up.
If the customer is using manual tracking via GTM or JavaScript API to create pageview events, Leadfeeder will start to ignore those once the company’s script is switched to “SPA Tracking”. This is done to prevent duplication of pageviews.
We’ll only ignore events that we already recorded, that is, changes in the page URL. Other specific events sent through manual tracking will continue to work.
What are the current limitations?
Leadfeeder app currently does not show the hash fragment in a page view
This means that if the hash fragment changes, we would identify a new page view but since we don’t show hash fragments, the app would display another page view with the same base URL. (i.e., duplicate pageviews)
This will be improved in the future by WebVisitors squad.