> For the complete documentation index, see [llms.txt](https://docs.pulseinsights.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pulseinsights.com/implementing-pulse-insights-dev/implementing-on-web-and-mobile-web/single-page-apps.md).

# Single Page Apps

Pulse Insights handles single page apps natively with no additional changes or modifications on your part.&#x20;

## On State Change

State changes are treated like new pageviews, and Pulse Insights will evaluate whether a survey is eligible to be returned on each state change.&#x20;

{% hint style="warning" %}
Don't re-load the Pulse Insights tag on each state change. It adds unnecessary overhead and could even interfere with proper functioning.
{% endhint %}

{% hint style="info" %}
Some browser have a back forward cache that preserves the state of the page when users navigate via back/forward buttons. In this case, the page doesn't call Pulse Insights again. Since Pulse Insights wasn't called, we won't increment an impression or evaluate frequency caps, but the user experience will perform as expected.
{% endhint %}

## For tags deployed prior to 2019 intending to use Single Page Apps

We recommend adding the following line to your code snippet above `'get', 'surveys'`.

```javascript
pi('pushBeforeGet', true);
```

This command will push the state before making the serve call for surveys and will ensure that the serving logic is using the latest URL for survey targeting.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.pulseinsights.com/implementing-pulse-insights-dev/implementing-on-web-and-mobile-web/single-page-apps.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
