---
updatedAt: 2025-06-17T21:38:19.000Z
agentTools:
  projectIndex: https://support.kissmetrics.io/llms.txt
---

# Tracking Page Views Using Google Tag Manager and a Single Page App

### Setup requirements:

For this tutorial we are assuming you have:

* Kissmetrics and Google Tag Manager Javascript snippets installed
* Fundamental knowledge of Javascript and HTML elements
* Basic understanding of Google Tag Manager

> 📘 Goal:
>
> We are going to go through the process of setting up a Page View event that will fire whenever a new page loads.  This event will capture the page URL as a property.

​

### Step 1: Create the Trigger

* Navigate to your GTM's container and create a new Trigger;

![](https://files.readme.io/8283659-01_new_trigger.png)

* Select the **Page View** Trigger Type;

![](https://files.readme.io/1d4dcea-02_trigger_type.png)

* Set the trigger to fire on **All Page Views**;

![](https://files.readme.io/d7e7f90-03_trigger_setting.png)

* Name the trigger *Page View* and save it.

![](https://files.readme.io/53d6a3f-04_name_trigger_and_save.png)

### Step 2: Create the Tag

Now we need to make the Tag that will use the **Page View** trigger we just created.

* Select the Tags category and create a new Tag

![](https://files.readme.io/4e7e850-small-05_adding_new_tag.png)

* Click on the **Triggering** box and select **Page View**

![](https://files.readme.io/26ec4b8-small-06_selecting_trigger.png)

* Click on the **Tag Configuration** box and select **Custom HTML**

![](https://files.readme.io/067d5c9-small-07_adding_custom_html.png)

* Enter the following Javascript

```javascript
  <script>
    var _kmq = _kmq || [];
    _kmq.push(["record", "Page Viewed", {"Viewed Page" : "Homepage"}])
  </script>
```

![](https://files.readme.io/ce79a5b-small-08_adding_js_code.png)

* We'll name this Tag *Page Views* and save it

![](https://files.readme.io/8eacb9f-small-09_naming_and_saving_tag.png)

* Publish the Container to make the Tag and Trigger live

![](https://files.readme.io/572f76a-small-10_publishing_changes.png)

### Step 3: View the Tag in Kissmetrics

In our Kissmetrics Live View we should be able to see an event fire whenever we load a page.

![](https://files.readme.io/0642ed8-small-11_event_in_the_live_view.png)

​\
This lets us know the Trigger and Tag are both working, however, we need to change our **Viewed Page** to match the URL of the page we are viewing.\
​

### Step 4: Add Unique URL to Page View

Back in our **Page Views** tag, let's declare a variable that captures the current URL and put that into our properties.  We'll do this by changing our custom HTML code to:

```javascript
  <script>
    var url = window.location.href
    var _kmq = _kmq || [];
    _kmq.push(["record", "Page Viewed", {"Viewed Page" : url}])
  </script>
```

![](https://files.readme.io/cb11603-small-12_updated_tag_code.png)

Make sure to save and publish this change.  Now the events in Kissmetrics will pass the page URL where "Homepage" was before.

![](https://files.readme.io/a0ed3e8-small-13_updated_url.png)