> 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/optimize-your-setup/google-tag-gateway-gtg/setup-gtg-via-cloudflare.md).

# Setup GTG via Cloudflare

Use the direct Cloudflare dashboard method when the GTM → Cloudflare OAuth connection fails with an "Access denied" error.

{% content-ref url="/pages/I26hhzVcMZdudkKjSP44" %}
[Google tag gateway (GTG)](/optimize-your-setup/google-tag-gateway-gtg.md)
{% endcontent-ref %}

*Category: Tracking setup · Reading level: Intermediate · Reading time: \~5 minutes*

Google Tag Gateway (GTG) loads your Google tags (GTM, GA4, Google Ads) from your own domain instead of directly from Google's servers. That gives you:

* Better data quality — fewer blocks by browser extensions
* First-party tracking — tags load as first-party content
* Higher conversion accuracy — Google reports \~11% more signal on average

## When do you use this method?

The standard way to set up GTG is via GTM → Sign in to Cloudflare. But this OAuth connection can fail with:

{% hint style="danger" %}
"Access denied. Check your sign-in information and permissions to update your Content Delivery Network."
{% endhint %}

This happens when:

* You were invited as a member on a client's Cloudflare account
* Account-wide API access is disabled (default on non-Enterprise accounts)
* The Cloudflare account owner can't complete the link themselves in GTM

In that case, use the direct Cloudflare dashboard method below — no GTM OAuth required.

### Requirements

| Requirement     | Details                                            |
| --------------- | -------------------------------------------------- |
| Cloudflare plan | Free or higher                                     |
| Cloudflare role | Super Administrator, Administrator, or Zaraz Admin |
| GTM container   | Installed on the website                           |
| Google Tag ID   | GTM-XXXXXXX (top-right in GTM)                     |

## Step-by-step setup

{% stepper %}
{% step %}

### Open Google Tag Gateway in Cloudflare

Log in to dash.cloudflare.com as the account owner (or as an invited member with sufficient rights). Select the domain you want to enable GTG on. In the left sidebar, scroll to **Web tag management → Google tag gateway**.

{% hint style="warning" %}
This needs to be done by someone with an account-level role. A domain-scoped role isn't enough.
{% endhint %}
{% endstep %}

{% step %}

### Configure Google Tag Gateway

Click **Configure** and fill in:

* **Google tag ID\*** — the website's GTM container ID, e.g. `GTM-AB123456`. Found top-right in the GTM interface.
* **Measurement path\*** — a path on the website that isn't in use yet, e.g. `/metrics`, `/gtm`, `/analytics`, or a random combination of letters/numbers (recommended).

{% hint style="success" %}
**Tip:** Use the default path Cloudflare suggests — it's a random combination that minimizes the chance of conflicts.
{% endhint %}

* **Set up tag** — leave off if the website already has a GTM snippet in the source code; turn on if Cloudflare should inject the tag automatically (no GTM snippet yet).

Click **Save**.
{% endstep %}

{% step %}

### Activate the toggle

After saving, a toggle appears on the Google Tag Gateway page. Turn it on.

Cloudflare now automatically injects the adjusted GTM snippet on the fly into every page on the domain — no source code changes needed.
{% endstep %}
{% endstepper %}

## Verifying your setup

**Method 1 — Check the page source** Go to the website → right-click → View Page Source (or Cmd+U / Ctrl+U) → search for the measurement path (e.g. `/metrics`). You should see a GTM snippet pointing to `yourdomain.com/[path]` instead of `googletagmanager.com`.

**Method 2 — Browser DevTools** Open DevTools (F12) → Network tab → reload the page → filter on your measurement path. Requests now run through your own domain ✅.

**Method 3 — Tag Assistant (most reliable)** Go to tagassistant.google.com → enter the website URL → Connect → navigate the site to trigger tags → Summary → Output → Hits Sent → confirm hits are sent via your measurement path.

## Common issues

**"Access denied" on the GTM OAuth link** Cause: Cloudflare API access is disabled for your member account — an Enterprise-only Cloudflare setting. Fix: Use the direct Cloudflare dashboard method described above.

**GTM status stays "Not started" after Cloudflare setup** Cause: GTM and Cloudflare aren't linked via OAuth, so GTM never receives a status update. Fix: This is expected with the direct Cloudflare method. Validate via Tag Assistant or DevTools instead — if requests run through your domain, it's working correctly.

**Tags load on admin pages (e.g. WordPress `/wp-admin`)** Cause: Cloudflare injects the snippet on every page on the domain. Fix: Set up a Cloudflare Configuration Rule to exclude the measurement path on admin URLs.

## GTM OAuth vs. Cloudflare dashboard method

|                                       | GTM OAuth    | Cloudflare dashboard      |
| ------------------------------------- | ------------ | ------------------------- |
| Automatic GTM configuration           | ✅ Yes        | ❌ No (not needed)         |
| Snippet injection by Cloudflare       | ✅ Automatic  | ✅ Automatic               |
| Website source code changes           | ❌ Not needed | ❌ Not needed              |
| Works as a member of a client account | ❌ Often not  | ✅ Yes                     |
| GTM status visible in the interface   | ✅ "Active"   | ⚠️ May show "Not started" |


---

# 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/optimize-your-setup/google-tag-gateway-gtg/setup-gtg-via-cloudflare.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.
