All Collections
Developer resources
Nextsale for Single Page Application (SPA)
Nextsale for Single Page Application (SPA)

Learn how to install Nextsale Pixel in a Single Page Application (SPA)

Neo Gurbanli avatar
Written by Neo Gurbanli
Updated over a week ago

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 the browser loading entire new pages. The goal is faster transitions that make the website feel more like a native app.

In a SPA, all necessary HTML, JavaScript, and CSS code is either retrieved by the browser with a single page load, or the appropriate resources are dynamically loaded and added to the page as necessary, usually in response to user actions. The page does not reload at any point in the process, nor does it transfer control to another page, although the location hash or the HTML5 History API can be used to provide the perception and navigability of separate logical pages in the application.

The default installation of Nextsale Pixel works well with traditional websites because the snippet code is run every single time the users load a new page. Since all new page content loads dynamically in a single page application the Nextsale Pixel installation snippet code only runs once. This means subsequent (virtual) ping from the Nextsale library must be send manually as new content is loaded.

When your application loads content dynamically and updates the URL in the address bar, the ping request should be sent to the Nextsale servers. To do that you just need to call the public nsio function with ping

Did this answer your question?