# Ptengine Measurement Configuration Guide for SPA Sites

## Ptengine Measurement Configuration Guide for SPA Sites

## **What is an SPA Page?**

SPA stands for Single Page Application.

In order to optimize content delivery speed and improve the overall performance of websites, the use of SPAs is becoming increasingly common these days.

## **Why Special Configuration is Required for Measuring SPA Pages**

Because SPAs load content in a different way than traditional websites, standard measurement methods cannot detect SPA page content changes and URL changes by default, which also affects the proper analysis of user behavior. Similarly, Ptengine cannot properly measure SPA pages with standard basic tags and requires special configuration.

As a solution, by configuring the Ptengine SPA-compatible tag, when page content changes, the SPA-compatible tag will fire and send information such as the updated page URL to Ptengine, allowing for proper measurement. Specific configuration methods are introduced below.

## **Explanation of Implementation Logic**

After the Ptengine basic tag is loaded on an SPA page, the Ptengine SPA-compatible tag is called from the "router change" function at the moment the page changes.

Google Tag Manager (hereinafter referred to as GTM) can easily identify history changes, so we recommend setting this as a trigger. Of course, manual configuration is also possible, but it requires cooperation from your technical team.

**Warning:**

If the page content changes but the URL does not change, you can use the tag below to generate a demo URL and then measure data with the new URL. However, please note that GTM cannot be used and [manual configuration](/en/faq/tag-and-domain/spa-tracking.md) will be required. For details on "URL/#location information", please refer to the [setPVTag](/en/faq/tag-and-domain/spa-tracking.md) section in this document.

`window._pt_sp_2 && window._pt_sp_2.push('setPVTag,URL/#location information,replace');`

## **Configuration Method with GTM**

1. Create a new tag in the GTM container where the basic tag is configured.
2. After setting the tag name, select "Custom HTML", enter the tag below, set the trigger to "History Change", and save.

```
window._pt_sp_2 && window._pt_sp_2.push('setPVTag,'+ location.href +',replace');
```

3. After confirming there are no issues, click the "Publish" button to publish.

####

## **Manual Configuration Method**

It is also possible to fire setPVTag manually, so when configuring manually, add the following tag to your page logic so that the Ptengine SPA-compatible tag is called from the "router change" function at the moment the page changes.

```
window._pt_sp_2 && window._pt_sp_2.push('setPVTag,'+ location.href +',replace');
```

If the page content changes but the URL does not change, use the tag below. For details on "URL/#location information", please refer to the "setPVTag" section in the document [here](/en/faq/tag-and-domain/spa-tracking.md).

```
window._pt_sp_2 && window._pt_sp_2.push('setPVTag,URL/#location information,replace');
```


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://helps.ptengine.com/en/faq/tag-and-domain/spa-tracking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
