Let AI assistants read and change your GTM Kit setup

GTM Kit registers abilities with the WordPress Abilities API, so an AI assistant connected through the MCP Adapter can read your container, consent and tracking health setup, and, if you switch it on, change a short list of settings after you confirm.

Last updated ·

From version 2.21, GTM Kit describes its own setup to AI assistants. An assistant connected to your site can read how GTM Kit loads Google Tag Manager, which consent GTM Kit sets, and whether tracking is healthy, from the same checks the GTM Kit settings and Site Health use. From version 2.24 it can also change a short list of settings, if you switch that on: every change is previewed first and applied only with a single-use confirmation code.

What this is for

WordPress 6.9 added the Abilities API: a standard way for plugins to describe what they can do, so other tools can find and call it. The WordPress MCP Adapter makes those abilities available to AI assistants that speak the Model Context Protocol (MCP), such as Claude, ChatGPT or Cursor.

With GTM Kit’s abilities, you can ask your assistant questions like “Which GTM container does this site load, and through which domain?”, “Is Consent Mode set up so analytics can ever be granted?” or “Does Site Health report any GTM Kit problems?”, and get an answer based on the site itself rather than a guess from the page source.

What an assistant can read

GTM Kit registers three abilities in the GTM Kit category (gtm-kit):

Get GTM Kit configuration (gtm-kit/get-configuration)

  • The container ID and the data layer name.
  • The server-side tagging domain, if one is set.
  • Which loader your pages use: the standard one, or the one Stape issues for your container, and whether a Stape loader is wanted and stored.
  • The Google tag gateway state: off, on and serving the container, on but falling back, or on but ruled out by a custom server-side tagging domain.
  • Whether GTM environment parameters are set (never their values).
  • The integrations that are switched on and whose plugin is active, and the GTM Kit version.
  • Whether GTM Kit sets Consent Mode defaults, and the consent state a new visitor gets per category before answering, from whichever consent source is in charge. If that source cannot tell without reading a visitor’s own choice, the answer says so (consent_state_basis is unavailable) instead of reporting your own consent as an administrator.
  • The consent platform GTM Kit detected, and which consent source is in charge.
  • Whether a consent integration owns consent, or GTM Kit’s defaults are the only source.
  • Whether analytics storage is granted before the visitor answers, and whether the defaults deny it with nothing on the site able to lift them.
  • How the purchase event’s customer details are treated when the page holds no consent state at all.

Get GTM Kit tracking health (gtm-kit/get-tracking-health)

  • The GTM Kit results you see yourself under Tools → Site Health, with their status (good, recommended or critical).
  • When the Google tag gateway is on, the result of its last stored check.
  • The result of GTM Kit’s daily check of a sample page: whether tracking was found, and whether it loads more than once.

With GTM Kit Premium (1.9 and later)

GTM Kit Premium adds two read abilities for server-side tracking. They are registered while your Premium licence is active, and need the same administrator access as the others.

  • Get GTM Kit webhook queue (gtm-kit/get-webhook-queue): whether purchase and order events go through the background queue, how many are waiting and how many delivery attempts they have had, when the oldest was queued, when the next attempt is due, and how many attempts are made before an event is given up. Failed events are not stored, so past failures are not reported.
  • Get GTM Kit order consent (gtm-kit/get-order-consent): for one WooCommerce order, given its ID, how consent resolves for its server-side event: the four Consent Mode types, whether they were captured in the browser at checkout, read from the WP Consent API, or taken from the unknown-consent setting, when they were captured, what the consent gate does with denied consent, and how unknown consent is treated. It returns no customer details, only the consent record.

Ask, for example, “Are any purchases waiting to reach the server container?” or “How did consent resolve for order 1234?”

What an assistant can change (from 2.24)

Two more abilities change settings. They are off until you switch them on (see Steps).

  • Preview a GTM Kit settings change (gtm-kit/preview-settings-change) works out what a change would store, without storing anything or sending any request. It returns each setting with the value it would store, anything that would be refused and why, side effects worth telling you about (for example, that renaming the data layer affects scripts outside GTM Kit), and a single-use confirmation code.
  • Apply a previewed GTM Kit settings change (gtm-kit/apply-settings-change) takes only that code and saves the change the way the settings screen does, with the same validation. It returns what was written and your configuration and consent status after the change.

The code works once, for the user it was issued to, for five minutes, and not after the settings changed in the meantime. The assistant shows you the preview and asks before it applies: the confirmation happens in your assistant, not in wp-admin.

Settings an assistant can change: the container ID, the data layer name, the server-side tagging domain, the Google tag gateway, whether Consent Mode defaults are set and the default for each consent category, and the WooCommerce, Contact Form 7 and Easy Digital Downloads integrations. GTM Kit Premium 1.9 and later add how unknown consent is treated (allow or deny) and the Gravity Forms integration. Changing unknown consent from deny to allow means orders without a consent record send customer details to your server container, so read that preview before you confirm. An assistant can never change the GTM environment parameters, the loader Stape issued for your site or a licence key.

What it cannot do

  • Change anything unless you switch it on. The read abilities only read. The two that change settings are not registered until you turn them on, and every change goes through a preview and your confirmation.
  • Run for anyone but administrators. Reading needs the manage_options capability. Changing settings needs the capability the GTM Kit settings screen requires, so if you have tightened it with the gtmkit_admin_capability filter, or on multisite, the same rule applies here. Other logged-in users, customers included, can see that the abilities exist, with their names and descriptions, but get an error if they try to run one.
  • Reveal secrets. GTM environment parameters and licence data are never included in an answer.
  • Contact anything outside your site. The abilities make no outbound requests. Checks that need one, such as the gateway check, are reported from the result GTM Kit already stored. Switching on the Google tag gateway is the one exception: it is checked over the network when the change is applied, as it is on the settings screen.

Steps

1. Update GTM Kit

Update to GTM Kit 2.21 or later to read, and 2.24 or later to change settings. GTM Kit requires WordPress 6.9, which includes the Abilities API, so nothing else is needed on the GTM Kit side. The abilities are registered by default. For the Premium abilities, update GTM Kit Premium to 1.9 or later, which requires GTM Kit 2.24.0.

2. Switch on changes (optional)

To let an assistant change settings, return true from the gtmkit_write_abilities_enabled filter. Add it from a plugin or your theme’s functions.php, for the same reason as below: WordPress builds its list of abilities once per request, early.

add_filter( 'gtmkit_write_abilities_enabled', '__return_true' );

3. Install the WordPress MCP Adapter

The WordPress MCP Adapter exposes your site’s abilities to AI assistants. Install and activate it following its own instructions.

4. Connect your assistant

Follow the MCP Adapter’s instructions for your assistant. For a remote site this usually means an application password for an administrator account (Users → Profile → Application Passwords). Use an account that is allowed to manage options, or the GTM Kit abilities will refuse to run.

The MCP Adapter’s default server lists your site’s abilities through its discover tool and runs them through its execute tool, so expect the assistant to look GTM Kit’s abilities up before calling them. If you connect over STDIO with WP-CLI, keep PHP notices off standard output (for example php -d display_errors=stderr), or the assistant receives them as broken responses.

5. Ask

Ask your assistant about your GTM Kit setup. It finds the GTM Kit abilities in the list the MCP Adapter provides and calls the one that fits the question.

Verify it worked

Ask the assistant which GTM container ID your site uses. It should give the ID shown under GTM Kit → Setup. Then ask for the GTM Kit Site Health results and compare them with Tools → Site Health. They come from the same checks, so they should match.

If you switched on changes, ask the assistant to preview changing a harmless setting, such as switching an integration you do not use on. It should show you the proposed value and ask before applying. Decline, and nothing changes.

Turn it off

To keep GTM Kit out of the Abilities API, and so out of every AI assistant connected to your site, return false from the gtmkit_abilities_enabled filter. Add it from a plugin or your theme’s functions.php: WordPress builds its list of abilities once per request, early, so a filter added later has no effect.

add_filter( 'gtmkit_abilities_enabled', '__return_false' );

To keep reading but stop changes, remove the gtmkit_write_abilities_enabled filter, or return false from it.

Common issues

The assistant does not see any GTM Kit abilities. Check that GTM Kit is 2.21 or later, that the MCP Adapter is active, and that nothing on the site returns false from gtmkit_abilities_enabled.

The assistant sees the abilities but gets an error running them. The account it connects with cannot manage options. Connect with an administrator account.

The gateway or sample-page results look out of date. They are the results GTM Kit stored the last time those checks ran, so the abilities never trigger a request of their own. The answer includes when each check ran.

The assistant does not see the abilities on a store with WP Rocket or WooCommerce’s MCP feature. Those plugins bundle older copies of the MCP Adapter, which before GTM Kit 2.24 hid GTM Kit’s abilities. Update GTM Kit to 2.24 or later.

The assistant reads but cannot change anything. Check that gtmkit_write_abilities_enabled returns true early enough (a plugin or functions.php), and that the account the assistant uses can change GTM Kit’s settings on the settings screen.

For developers

  • gtmkit_abilities_writable_settings adds settings an assistant may change, as group.key. It only adds: GTM Kit’s own list is always kept, and environment parameters, the Stape-issued loader and anything naming a licence are always removed.
  • gtmkit_settings_changed_by_ability fires after an assistant’s change is saved, with the user who confirmed it and the settings written.

Full signatures are on Actions & Filters.

← Previous

Previous article

Next →

Next article