support home

Back to website
Welcome
Login  Sign up

Page view event for Single Page Applications

Hello everyone.

I'm trying to use iubenda with Single Page Application. And it seems like, while navigating through the pages, the page view event does not trigger. Can you give an advice on how to make it work in SPA?


4 people like this idea
  • I like so mutch G.
  •  In the case of traditional websites, Google Analytics works fine because the code snippet is loaded every time the page is loaded. But in the case of a single page application, content is loaded dynamically which means the page refresh happens only once and Google Analytics runs only once on the page

  •  Keep it up

  • In general, GA works pretty well. Unfortunately it doesn't work well on single page applications as page refresh itself only once so does the GA. Due to this reason, the page view event does not trigger. 



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

  • I am also interested in its answer. I want to make a SPA

  • Actually, Google Analytics functions work properly on conventional websites since the code snippet is loaded each time the page is requested. A single-page application 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. The goal is faster transitions that make the website feel more like a native app.

  • +1

  • When using iubenda with a Single Page Application (SPA), you may encounter issues with the page view event not triggering as expected. This is because SPAs typically load pages dynamically without actually navigating to a new page, so the standard iubenda script may not capture these page views.

    To make iubenda work with your SPA, you can manually trigger the page view event each time the user navigates to a new "page" within the SPA. You can do this by calling the following function:


    scss

    Copy code

    iubenda.consent.triggerPageView();


    You can call this function whenever your SPA updates the content of the page, such as when the user navigates to a new section or loads new content via AJAX.

     

     

  • very informative .

  •  

    I am also interested in its answer too. I want to make a SPA.


Login or Signup to post a comment