> For the complete documentation index, see [llms.txt](https://docs.adpage.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.adpage.io/getting-started/using-the-gtm-preview-mode.md).

# Using the GTM Preview Mode

How to use the Google Tag Manager preview mode in the web and server container to debug and test

Google Tag Manager's Preview Mode is a valuable tool that helps you test tags and triggers before you publish your changes. But it is also needed to debug your trackings setup. Let's take a look at when and how to use it.

### What is GTM's preview mode?

Preview mode (also called preview and debug mode) in Google Tag Manager is a built-in feature that lets you test tags, triggers and variables in real time on your website or in your server container. You use this mode before you publish your changes, but also to debug in a test environment, so real visitors don't notice anything.

In a server-side tagging setup you work with two containers in Google Tag Manager: a web container and a server container. Both containers have their own preview mode, and each one works slightly differently. In this article we explain when and how to use the preview mode of the GTM web container, and when and how to use the preview mode of the GTM server container.

Let's start with the web container.

{% stepper %}
{% step %}

#### Web container preview mode

There are three key moments where you use preview mode in the Google Tag Manager web container:

* After setting up new tags and triggers.
* To check whether your existing tags and triggers still fire correctly.
* After making changes to your website.

#### 1. Creating new tags and triggers

After setting up new tags and triggers, it's essential to use preview mode before you publish your container. To test them, click 'Preview' in the top right of the container you're working in. In the popup of the preview window, enter the URL of the website that is connected to this container. Your site now opens in a new tab in a test environment.

Say you've set up a tag and trigger for a specific button on a certain page of your site. In the test environment, navigate to that page and perform the action, for example clicking the button. In the preview tab you can then see which tags fired and which didn't. You can also review this per page and per site-interaction in the vertical menu on the left.

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2FEz4x8RVzjTaRGzwqhmKV%2Fimage.png?alt=media&amp;token=918a6c28-9641-4dc6-9bdb-2de688ea2d7f" alt=""><figcaption></figcaption></figure>

#### 2. Check whether your existing tags and triggers still fire

If you notice that certain events aren't coming in, or aren't coming in correctly, in platforms such as Meta Ads or Google Analytics, the first thing to check is whether the tags and triggers in Google Tag Manager still fire correctly.&#x20;

Start by performing the action that should make the tag fire. Select that session event in the vertical menu on the left. In the list of tags that didn't fire (Tags not fired), select the tag that should have fired. Under **Firing Triggers** you'll then see an overview explaining why that tag didn't fire.

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2F0XmHsriTwHsbKESyMHgO%2Fimage.png?alt=media&amp;token=44b61a90-c8ab-4e3d-8d15-29b21d94093c" alt=""><figcaption></figcaption></figure>

#### 3. Changes made to your site

When you make changes to your site, such as changing URLs, updating button and link texts, or adjusting the checkout flow, it's important to make sure those changes don't break your measurement. If you open your site in the preview mode, you can walk through all of your changes and perform the relevant events. Preview mode lets you keep track of which tags do and don't fire.

#### Troubleshooting tags that didn't fire

If tags didn't fire that should have, click the event where you expected the tag to fire in the vertical menu on the left. Select the event, then click the tag that didn't fire to see what's wrong with the trigger. Inside that tag you can find out why the trigger didn't work in the **Firing Triggers** section, and make changes based on that information.

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2FcFdFswuFLkMBIqpKdidE%2Fimage.png?alt=media&amp;token=782fe899-0680-4740-862e-bbd755713226" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Server container preview mode

There are two key moments where you use preview mode in the Google Tag Manager server container:

* When you create new server-side tags and triggers.
* When you make changes to your server-side tagging setup, or when the incoming requests from your web container change.

#### 1. Testing new tags and triggers

Preview mode in the server container works differently from the web container, because it waits for incoming events from your website instead of you clicking through your site directly. When you open preview mode, your website doesn't open automatically. You'll only see an overview of incoming requests in the preview mode interface once you start sending events to the server container URL when you have opened the website within the same browser.

So a requirement for using the GTM server container preview mode is that you've made the necessary Google tag configuration settings in your GTM web container.

In the overview on the left you'll see the incoming requests in chronological order, where the GA4 client turns them into a readable event. In the overview on the right you can see the tags that are triggered when the event arrives.&#x20;

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2FxjSBxLOJINc8Lg2NdNrF%2Fimage%20(50).png?alt=media&amp;token=032271a4-328d-4e73-bbb5-dfc9b1d1bab2" alt=""><figcaption></figcaption></figure>

#### 2. Testing changes to your web container

When you make changes in the GTM web container and want to know whether this affects your GTM server container tags, you can check this in preview mode as well. When an event comes in, you expect specific tags to be triggered or you want specific parameters to be sent towards your marketing platforms. If that doesn't happen, you know something is wrongly set up in the GTM web container or in the server container.

If you make changes to the parameters of an event tag, you can easily review them in the Event Data tab of the incoming request. The Event Data tab shows you which client processed the incoming request and which event data you can work with in your server tags, triggers and variables.

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2Fw8TdQJC33TSFl5WEye3v%2Fimage.png?alt=media&amp;token=ece15494-4472-4094-b104-f0816e8e098e" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

***

### No requests coming into your GTM server container preview mode?

If you are testing your server-side tagging setup and no event requests show up in the server container preview mode? Don't worry. We'll explain the most common causes step by step so you can get back to testing quickly.

{% stepper %}
{% step %}

#### Check the basics

Before you dig deeper, confirm that your server container is live and responding.

* **Health check:** open a new tab, go to your server container URL and add `/healthy` to it. You should see `ok`.

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2FiMw3coNsBq74Hwx1CszA%2Fimage.png?alt=media&amp;token=7b89344d-2329-44c5-b62b-56be4d71d0ce" alt=""><figcaption></figcaption></figure>

* **Test endpoint:** open a new tab, go to your server container URL and add `/test`. A `400` error is expected and fine. What matters is that you see this request arrive in your preview mode. If it does, your container and preview session are working.

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2F4h6bqxNc8OzLLSJd4v39%2Fimage.png?alt=media&amp;token=3eebbdfe-975e-4848-9a19-c9c95c21cdc1" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Verify the server container URL

Using the wrong server container URL in your Google tag is one of the most common causes. Make sure the server container URL in your Google tag configuration (in your GTM web container) matches exactly the URL where you are running the sGTM preview. Double-check for typos, a missing subdomain, or `http` instead of `https`.
{% endstep %}

{% step %}

#### Check whether your Google tag configuration is being overwritten

Another frequent cause is a second source on the website overwriting your Google tag configuration, usually a hardcoded gtag.js script.

**How to check:**

1. Open the **Network** tab in your browser developer tools.

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2FZRB3XReVlPcd6gXnqM01%2Fimage.png?alt=media&amp;token=45bde7f2-d593-4b55-aba8-001903fd462c" alt=""><figcaption></figcaption></figure>

2. Enable **Preserve log** so events are kept when the page changes.

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2Fvcu613SHxIVCAZlizATz%2Fimage.png?alt=media&amp;token=6a828b0b-9d2d-43e4-9af8-39221262de5e" alt=""><figcaption></figcaption></figure>

3. Filter on your GA4 measurement ID.

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2FxIlpGqfi9nDHtXZ6W7Ej%2Fimage.png?alt=media&amp;token=23da506b-4ae2-4225-b117-48b59bf55d68" alt=""><figcaption></figcaption></figure>

4. Look at where the requests are going. If they go to `googletagmanager.com` or `region1.google-analytics.com` instead of your server container URL, your Google tag configuration in the GTM web container is being overwritten by a gtag.js script on the website.

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2FFibfEEsWJhoMHjPzq7kv%2Fimage.png?alt=media&amp;token=3965d0eb-7005-4069-aa39-7561993360ee" alt=""><figcaption></figcaption></figure>

**Possible causes:**

* A gtag.js script in the website source.
* Multiple Google tags using the same measurement ID.
* The standard Google Tag Manager script running alongside the tagging pixel script.
  {% endstep %}

{% step %}

#### Still nothing?

A few less obvious things worth checking:

* **Same browser, same session.** Preview mode only captures traffic from the browser session that was started from the preview window. Opening the site in another browser, another profile, or in incognito breaks that link. Use the preview window itself, or the "Send requests to..." tab it opens.
* **Ad blockers and privacy extensions.** These can block requests before they ever leave the browser. Test with extensions disabled or in a clean profile.
* **Consent state.** With Consent Mode active, tags may be waiting for consent and simply never fire. Accept consent on the page and check again.
* **Web container preview.** Check whether the tag fires at all in the web container preview. If the tag doesn't fire there, the problem is in the web container, not on the server side.
  {% endstep %}
  {% endstepper %}


---

# 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 dynamically by asking a question.

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

```
GET https://docs.adpage.io/getting-started/using-the-gtm-preview-mode.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
