Silvertrail documentation

Silvertrail holds back everything a site loads from other servers until the visitor agrees, and passes the choice on to Google and to the site's own code. It runs on any HTML page, on WordPress and on Kirby, with the same rules, script and banner.

These pages are the complete reference for developers and their agents, and WordPress's names are the names on every platform. The website shows the platform you pick, and https://silvertrail.marcwieland.name/llms.txt lists a Markdown copy for each. In the pages themselves, code is labelled with its platform, as in php Kirby, and text for some platforms sits between a ::: Kirby line and a ::: line.

Install

HTML

npx @mawiswiss/silvertrail init

WordPress

wp plugin install silvertrail --activate

Kirby

composer require mawiswiss/silvertrail-kirby

WordPress

The plugin also installs from Plugins › Add New, and its page is on WordPress.org. From then on, YouTube, Vimeo and Google Maps embeds wait behind a placeholder.

Kirby

The plugin's page is in Kirby's plugin directory. silvertrail-kirby.zip from a release on GitHub also unpacks to site/plugins, and https://github.com/mawiswiss/silvertrail-kirby.git goes there as a Git submodule.

From then on, YouTube, Vimeo and Google Maps embeds wait behind a placeholder. Silvertrail adds the banner, the script and the stylesheet to every page with an <html> or <body> tag after its template renders, so the templates need no change. A fragment without them, such as a partial that a script loads, only has its scripts and embeds held back. Empty Kirby's page cache after each update of Silvertrail, because a cached page still links to the old script, which Kirby no longer serves.

HTML

The package is @mawiswiss/silvertrail on npm. npx @mawiswiss/silvertrail init copies silvertrail.js, silvertrail.css and webmcp.js to silvertrail/, writes .well-known/gpc.json and adds a few lines to the project's AGENTS.md, so a later agent session keeps to the markup and runs the check. --no-agents leaves that file alone. Without npm, copy the three files from silvertrail-web.zip of a release on GitHub. Each page then carries the markup WordPress and Kirby print, as The markup on an HTML page shows.

Set up in code

The same setup on each platform: Google Tag Manager, HubSpot as a service of its own, a bar at the bottom and choices kept for 12 months.

HTML

<link rel="stylesheet" href="/silvertrail/silvertrail.css">
<script type="application/json" id="silvertrail-config">
{
	"services": {
		"google-tag-manager": { "tag_id": "GTM-XXXXXXX" },
		"hubspot": {
			"group": "marketing",
			"name": "HubSpot",
			"provider": "HubSpot, Inc.",
			"purpose": "Tracks form conversions.",
			"privacy_url": "https://legal.hubspot.com/privacy-policy",
			"hosts": ["js.hs-scripts.com", "hubspot.com"]
		}
	},
	"layout": "bar",
	"bar_position": "bottom",
	"expiry_months": 12,
	"privacy": "/privacy.html"
}
</script>
<script src="/silvertrail/silvertrail.js"></script>

WordPress

add_action( 'silvertrail_register', function () {
	silvertrail_register_service( 'google-tag-manager', [ 'tag_id' => 'GTM-XXXXXXX' ] );

	silvertrail_register_service( 'hubspot', [
		'group'       => 'marketing',
		'name'        => 'HubSpot',
		'provider'    => 'HubSpot, Inc.',
		'purpose'     => 'Tracks form conversions.',
		'privacy_url' => 'https://legal.hubspot.com/privacy-policy',
		'hosts'       => [ 'js.hs-scripts.com', 'hubspot.com' ],
	] );
} );

add_filter( 'silvertrail_settings', function ( $settings ) {
	$settings['layout']          = 'bar';
	$settings['bar_position']    = 'bottom';
	$settings['floating_button'] = 'auto';
	$settings['expiry_months']   = 12;
	return $settings;
} );

Kirby

<?php

return [
	'mawiswiss.silvertrail' => [
		'services' => [
			'google-tag-manager' => ['tag_id' => 'GTM-XXXXXXX'],
			'hubspot'            => [
				'group'       => 'marketing',
				'name'        => 'HubSpot',
				'provider'    => 'HubSpot, Inc.',
				'purpose'     => 'Tracks form conversions.',
				'privacy_url' => 'https://legal.hubspot.com/privacy-policy',
				'hosts'       => ['js.hs-scripts.com', 'hubspot.com'],
			],
		],
		'layout'          => 'bar',
		'bar_position'    => 'bottom',
		'floating_button' => 'auto',
		'expiry_months'   => 12,
	],
];

WordPress

Put the hooks wherever the site keeps its own code: the theme's functions.php, a site plugin or a must-use plugin. Their callbacks run only while Silvertrail is active, so they do no harm when it is not. Run wp silvertrail validate until it reports no problem, and wp silvertrail settings to see every value marked code.

Kirby

The options go into site/config/config.php. Run kirby silvertrail:validate until it reports no problem, and kirby silvertrail:settings to see every value marked code.

HTML

The head block comes first in each page's <head>, without defer or async, so Google Consent Mode's defaults are set before any Google tag and window.silvertrail exists for every later script. The config comes right before the script, which reads it while it runs, and a returning visitor who allowed an embed sees it without its placeholder first. The floating button is part of the page's markup, so it is not in this config. Run npx @mawiswiss/silvertrail check until it reports no issue.

Platforms

The rules, the presets, the groups, the JavaScript API, the events, the cookie, Google Consent Mode, Global Privacy Control and the banner's look work the same on every platform. Core and platforms explains why. This is what differs between them:

WordPress Kirby HTML
The setup PHP on the silvertrail_register action and the filters mawiswiss.silvertrail in the site config the config in each page's head
The admin Settings › Silvertrail the Panel's Privacy tab none, the config holds every decision
The banner and the placeholders printed by the plugin added after each page renders in the page's markup
Scripts held back marked scripts and enqueued handles marked scripts and scripts from a service's hosts marked scripts
The shell wp silvertrail kirby silvertrail: with Kirby CLI npx @mawiswiss/silvertrail
Hooks actions and filters Kirby hooks, such as silvertrail.config the browser's events
Asking again a revision that rises when the services change the same a hash of the services, and revision by hand
Consent records a database table a JSON file under data_root a URL of your own in record
The Leak check in the admin /silvertrail/leak-check for Panel users npx @mawiswiss/silvertrail check --browser
Abilities over MCP, Write with AI and the WP Consent API yes no no

How it works

  • Services and groups. A service is anything the site loads from another server. It belongs to a group, such as statistics or marketing. Presets cover the common trackers and embeds, and the setup registers the rest.
  • Nothing loads before yes. Marked scripts wait as type="text/plain", and embeds wait in a <template> behind a placeholder, as Gate a script shows. Gated scripts run in their original order once allowed, external and inline.
  • The browser decides. Every gated script and embed is in the page blocked, and Silvertrail's script decides on each page view. That is why page caches need no setup, and why server code reads the choice only on requests a cache never serves. A stale cached page neither asks again nor overwrites a newer choice.
  • One cookie. The choice lives in a first-party cookie. When the set of services changes, every visitor is asked again.
  • One choice, passed on. Every choice goes to Google Consent Mode. Other code and the site's own scripts read the same choice through window.silvertrail and the silvertrail:change event, and the API lists them all.
  • Several ways to answer. The banner asks visitors, with "Accept all" and "Only essential" as the same button side by side. An embed asks on its own placeholder. A browser that sends Global Privacy Control gets "only essential" without a banner, and an agent in a browser with WebMCP answers through tools.
  • Built for agents. The shell lets an agent check its own work, and the WebMCP tools let it check a site in the browser. Agents covers each of them.
  • Mistakes are loud. An unknown key, a tag ID that does not fit or an invalid setting is reported, and the shell lists them all.
  • Small and self-contained. The front end adds one script and one stylesheet, with no external dependencies. Only a browser with WebMCP fetches a second small script for the agent tools.

WordPress and Kirby

Code wins over the admin. The admin holds only decisions, and it marks every field that code sets.

Where each concern lives

WordPress

What Where
Services and groups silvertrail_register action with silvertrail_register_service() and silvertrail_register_group(), see Services and groups
Last word on services silvertrail_config filter, see The whole config
Settings silvertrail_settings filter, see Settings
Reading and setting the choice silvertrail_has(), window.silvertrail, the silvertrail:change and silvertrail:before-prompt events, see API
Look the theme's theme.json, the silvertrail_design and silvertrail_reopen_icon filters, the theme's silvertrail/silvertrail.css, template overrides, see Style the banner
Texts the theme's silvertrail/texts-{locale}.json, the silvertrail_translation and silvertrail_texts filters, see Texts
Records silvertrail_recorded action, see Records
Shell wp silvertrail services, settings, validate, ask-again, write-styles and records export, see Shell
Agents the WebMCP tools and the abilities through the MCP Adapter, see Agents
Privacy page and imprint WordPress's privacy policy page and imprint_page, see Privacy and imprint pages
What the plugin does not ship regions, opt-out and other needs solved in the site's own code, see Recipes

Kirby

What Where
Services and groups services and groups under mawiswiss.silvertrail in site/config/config.php, see Services and groups
Last word on services the silvertrail.config hook, see The whole config
Settings their own names in the config, and the Panel's Privacy tab, see Settings
Reading and setting the choice silvertrail()->has(), window.silvertrail, the silvertrail:change and silvertrail:before-prompt events, see API
Look the design option, the silvertrail.design and silvertrail.reopenIcon hooks, site/silvertrail/silvertrail.css, template overrides, see Style the banner
Texts site/silvertrail/texts-{language}.json, the Panel and the texts option, see Texts
Records data_root and the silvertrail.recorded hook, see Records
Shell kirby silvertrail:validate, services, settings, ask-again, styling-brief, html-check and records, see Shell
Agents the WebMCP tools and the shell, see Agents
Privacy page and imprint the privacy and imprint options or the Panel, see Privacy and imprint pages
What the plugin does not ship regions, opt-out and other needs solved in the site's own code, see Recipes

HTML

What Where
Services and groups services and groups in the config of each page's head, see Services and groups
The banner, placeholders and floating button the page's markup, see The markup on an HTML page
Settings their own names in the config, see Settings
Reading and setting the choice window.silvertrail, the silvertrail:change and silvertrail:before-prompt events, see API
Look the --silvertrail-* custom properties in the site's CSS, see Style the banner
Texts the banner's markup and the config's texts, see Texts
Records a URL of your own in record, see Records
Shell npx @mawiswiss/silvertrail init, update, check and markup, see Shell
Agents the Silvertrail skill, also as a Claude Code plugin, npx @mawiswiss/silvertrail check and the WebMCP tools, see Agents
Privacy page and imprint the banner's links, see Privacy and imprint pages
What Silvertrail does not ship regions, opt-out and other needs solved in the site's own code, see Recipes

What it does not do

Silvertrail does not implement the IAB Transparency and Consent Framework, so an ad network that requires a TCF consent string needs a different banner. It does not detect countries. A site that treats regions differently decides in the silvertrail:before-prompt event, as the recipes show. It does not crawl the site for cookies either. The Leak check looks at the pages you list and shows what they actually load.

Pages

  • Services and groups: services, presets, groups, gated scripts and embeds.
  • Settings: every setting, its values, where it is set and the keys of each platform.
  • API: reading and changing the choice, the events, the cookie and every hook.
  • Reopen the preferences: links, menus and the floating button.
  • Style the banner: the design values, your own stylesheet, writing it with AI and templates.
  • Texts: where texts come from and every text key.
  • Consent signals: Google Consent Mode, Global Privacy Control and the other signals Silvertrail passes on.
  • Records: what is stored, for how long, and how to keep records elsewhere.
  • Leak check: what a page loads before and after consent, and the same check in CI.
  • Shell: every command on the shell.
  • Agents: setting up and checking a site with an agent, and the WebMCP tools.
  • Cookie consent on a landing page: a new landing page with a map, a video or analytics, set up by hand or with an agent.
  • Recipes: use cases Silvertrail does not ship, solved with the site's own code, such as regions and opt-out.
  • Privacy and imprint pages: which pages a site needs, what goes on them and how Silvertrail links them.
  • Core and platforms: how one core and a small adapter per platform fit together, and their licences.