# Page view event for Single Page Applications

**URL:** <https://support.iubenda.com/t/page-view-event-for-single-page-applications/4008>\
**Category:** Feature requests\
**Created:** [May 19, 2022, 2:33pm UTC](https://support.iubenda.com/t/page-view-event-for-single-page-applications/4008 "2022-05-19T14:33:07Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexandr.stepykin](https://avatars.discourse-cdn.com/v4/letter/a/d07c76/32.png) [@alexandr.stepykin](https://support.iubenda.com/u/alexandr.stepykin)\
**Post date:** [May 19, 2022, 2:33pm UTC](https://support.iubenda.com/t/page-view-event-for-single-page-applications/4008/1 "2022-05-19T14:33:07Z")

</div>

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?

* * *

_Importato da [support.iubenda.com](http://support.iubenda.com) (topic #42000300496) · 👍 4 upvote su Freshdesk · 👁 1385 visualizzazioni_

---

<div class="post-metadata">

**Author:** ![gb\_user](https://avatars.discourse-cdn.com/v4/letter/g/94ad74/32.png) [@gb\_user](https://support.iubenda.com/u/gb_user)\
**Post date:** [May 23, 2022, 11:53am UTC](https://support.iubenda.com/t/page-view-event-for-single-page-applications/4008/2 "2022-05-23T11:53:10Z")

</div>

I like so mutch  
G.

---

<div class="post-metadata">

**Author:** ![jchadwickson264](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@jchadwickson264](https://support.iubenda.com/u/jchadwickson264)\
**Post date:** [August 12, 2022, 5:09am UTC](https://support.iubenda.com/t/page-view-event-for-single-page-applications/4008/3 "2022-08-12T05:09:06Z")

</div>

&nbsp;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

---

<div class="post-metadata">

**Author:** ![jchadwickson264](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@jchadwickson264](https://support.iubenda.com/u/jchadwickson264)\
**Post date:** [August 12, 2022, 5:14am UTC](https://support.iubenda.com/t/page-view-event-for-single-page-applications/4008/4 "2022-08-12T05:14:25Z")

</div>

&nbsp;Keep it up

---

<div class="post-metadata">

**Author:** ![haideralichaudhry2](https://avatars.discourse-cdn.com/v4/letter/h/34f0e0/32.png) [@haideralichaudhry2](https://support.iubenda.com/u/haideralichaudhry2)\
**Post date:** [October 7, 2022, 7:36am UTC](https://support.iubenda.com/t/page-view-event-for-single-page-applications/4008/5 "2022-10-07T07:36:26Z")

</div>

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[.](https://superbotanicals.co/)&nbsp;Due to this reason,&nbsp;the page view event does not trigger.&nbsp;

---

<div class="post-metadata">

**Author:** ![hamza.iostream21](https://avatars.discourse-cdn.com/v4/letter/h/35a633/32.png) [@hamza.iostream21](https://support.iubenda.com/u/hamza.iostream21)\
**Post date:** [November 7, 2022, 2:21pm UTC](https://support.iubenda.com/t/page-view-event-for-single-page-applications/4008/6 "2022-11-07T14:21:52Z")

</div>

A&nbsp;single-page application&nbsp;(SPA) is a&nbsp;web application&nbsp;or&nbsp;website&nbsp;that interacts with the user by dynamically rewriting the current&nbsp;web page&nbsp;with new data from the&nbsp;web server, instead of the default method of a&nbsp;web browser&nbsp;loading entire new pages. The goal is faster transitions that make the website&nbsp;feel&nbsp;more like a&nbsp;native&nbsp;app.

---

<div class="post-metadata">

**Author:** ![miltosjohan673](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@miltosjohan673](https://support.iubenda.com/u/miltosjohan673)\
**Post date:** [November 24, 2022, 11:40am UTC](https://support.iubenda.com/t/page-view-event-for-single-page-applications/4008/7 "2022-11-24T11:40:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dragoncityapk01](https://yyz2.discourse-cdn.com/flex048/user_avatar/support.iubenda.com/dragoncityapk01/32/566_2.png) [@dragoncityapk01](https://support.iubenda.com/u/dragoncityapk01)\
**Post date:** [April 5, 2023, 4:07pm UTC](https://support.iubenda.com/t/page-view-event-for-single-page-applications/4008/8 "2023-04-05T16:07:44Z")

</div>

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&nbsp;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.

---

<div class="post-metadata">

**Author:** ![03p9pv](https://avatars.discourse-cdn.com/v4/letter/0/94ad74/32.png) [@03p9pv](https://support.iubenda.com/u/03p9pv)\
**Post date:** [April 10, 2023, 7:45pm UTC](https://support.iubenda.com/t/page-view-event-for-single-page-applications/4008/9 "2023-04-10T19:45:31Z")

</div>

+1

---

<div class="post-metadata">

**Author:** ![luciamartyn522](https://yyz2.discourse-cdn.com/flex048/user_avatar/support.iubenda.com/luciamartyn522/32/578_2.png) [@luciamartyn522](https://support.iubenda.com/u/luciamartyn522)\
**Post date:** [April 29, 2023, 11:31am UTC](https://support.iubenda.com/t/page-view-event-for-single-page-applications/4008/10 "2023-04-29T11:31:30Z")

</div>

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.

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![waqask66660](https://avatars.discourse-cdn.com/v4/letter/w/d07c76/32.png) [@waqask66660](https://support.iubenda.com/u/waqask66660)\
**Post date:** [May 8, 2023, 2:29pm UTC](https://support.iubenda.com/t/page-view-event-for-single-page-applications/4008/11 "2023-05-08T14:29:01Z")

</div>

very informative .

---

<div class="post-metadata">

**Author:** ![usaads223](https://avatars.discourse-cdn.com/v4/letter/u/eada6e/32.png) [@usaads223](https://support.iubenda.com/u/usaads223)\
**Post date:** [May 26, 2023, 11:13pm UTC](https://support.iubenda.com/t/page-view-event-for-single-page-applications/4008/12 "2023-05-26T23:13:59Z")

</div>

&nbsp;

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