On this page
@addTagHelper *, Webority.Ui.RazorFull setup
Put the tag once in the head, with ids from your marketing config, and the consent banner after it.
Head with consent banner
The ids come from your product's marketing config, never hardcoded.
Ask every visitor first
Use strict opt-in for a site whose policy asks every visitor first, in every country.
Strict opt-in everywhere
For a site whose policy promises consent first in every country. Consent Mode starts denied everywhere, Tag Manager and Ahrefs load only after the visitor consents, Accept grants analytics but no Google ad signals, and the choice lasts six months.
Every option
Every value of every prop, one cell each.
gtm-id: any string
gtm-id="GTM-XXXX"Loads the Google Tag Manager container with this id.
clarity-id: any string
clarity-id="abcdefghij"Loads Microsoft Clarity for this project id.
ahrefs-key: any string
ahrefs-key="your-key"Loads Ahrefs Web Analytics with this key.
cookie-domain: any string
cookie-domain=".example.com"The consent record spans this domain and its subdomains.
requires-opt-in: true, false or omitted
requires-opt-in="true"The opt-in default is on in every country.
requires-opt-in="false"The opt-in default is off in every country, so consent defaults to granted.
requires-opt-in omitted (default)Decided by the visitor's country: the EEA, the UK and Switzerland opt in, everywhere else defaults to granted.
strict-opt-in: true or false
strict-opt-in="true"Asks every visitor first, in every region.
strict-opt-in="false" (default)Consent follows requires-opt-in and the visitor's country.
ad-storage: true, false or omitted
ad-storage="true"Marketing consent also grants Google's ad signals.
ad-storage="false"Marketing consent grants analytics only, never the ad signals.
ad-storage omitted (default)On, or off under strict-opt-in.
consent-days: a number of days
consent-days="365" (default)The visitor's choice lasts a year.
consent-days="182"The visitor's choice lasts six months.
region-cookie: a cookie name
region-cookie="region"A cookie the host sets to eea or other. Other starts with analytics on.
region-cookie omitted (default)No region cookie: a visitor with no saved choice is asked first.
load-delay: idle or omitted
load-delay="idle"Starts the marketing tags after load and idle time, or the first interaction.
load-delay omitted (default)The marketing tags are not held back after load.
posthog-key: a project key
posthog-key="your-project-key"Starts PostHog with posthog-host. Set both or neither.
posthog-host: an address
posthog-host="/ph"The PostHog ingest address, such as a same-origin proxy path.
product: a name
product="your-product"The product name on every PostHog event. Required with posthog-key.
surface: a name
surface="website"The surface name on every PostHog event. Required with posthog-key.
environment: a name
environment="production"The environment name on every PostHog event. Local sends nothing.
posthog-replay: true or false
posthog-replay="true"Records session replay with analytics consent. Inputs and text are masked.
posthog-replay="false" (default)No session replay.
posthog-heatmaps: true or false
posthog-heatmaps="true"Sends heatmap points, cookieless and anonymous without analytics consent.
posthog-heatmaps="false" (default)No heatmap points.
posthog-exceptions: true or false
posthog-exceptions="true"Sends uncaught page errors to PostHog error tracking.
posthog-exceptions="false" (default)Page errors are not sent.
posthog-web-vitals: true or false
posthog-web-vitals="true"Sends field Core Web Vitals as $web_vitals events, with the element and script detail.
posthog-web-vitals="false" (default)No vitals events.
posthog-web-vitals-sample-rate: above 0 and at most 1
posthog-web-vitals-sample-rate="1" (default)Every page load reports.
posthog-web-vitals-sample-rate="0.1"One page load in ten reports.
posthog-web-vitals-deploy-version: a release id
posthog-web-vitals-deploy-version="deploy-42"Stored on every vitals event, so a regression can be tied to a deploy.
When to use
Use it when
- Any Razor page or layout that needs consent, tags, and attribution wired up in one line.
- You already have
<app-consent-banner>on the page (or in the layout) and want it to open and re-sync automatically.
Reach for something else when
- You're on the React surface. → initConsent / loadTags / captureAttribution from @webority/analytics, at your app's bootstrap
Reference
Try every prop, read the full list, and check keyboard and screen reader behaviour.
Every attribute, shown as the markup it produces. This page cannot render the include live, because a second copy would re-initialise the consent record this layout already set up, so try the real thing on the AppConsentBanner page instead.
21 props.
Less common 21 props
| Prop | Type | Default | Description |
|---|---|---|---|
| gtm-iddefault - | string | - | Google Tag Manager container id. |
| clarity-iddefault - | string | - | Microsoft Clarity project id. |
| ahrefs-keydefault - | string | - | Ahrefs Web Analytics key. |
| cookie-domaindefault - | string | - | Cookie domain the consent record spans (e.g. website + portal subdomains). |
| requires-opt-indefault - | bool? | - | Force the opt-in consent default on or off. Omit to decide from the visitor's country (the CF-IPCountry header): the EEA, the UK and Switzerland opt in, everywhere else defaults to granted, and a missing/unrecognised country opts in. |
| strict-opt-indefault false | bool | false | Ask every visitor first, in every region: Consent Mode starts denied everywhere, and Tag Manager and Ahrefs load only after consent. Cannot be combined with requires-opt-in="false". |
| ad-storagedefault - | bool? | - | Whether marketing consent also grants Google's ad signals. Omit for the default: on, or off under strict-opt-in. |
| consent-daysdefault 365 | int? | 365 | How many days the visitor's choice lasts. |
| region-cookiedefault none | string | none | Name of a cookie the host sets to eea or other. With no saved choice, other starts with analytics on and the banner still offers the opt-out; eea or no cookie asks first. Ignored under strict-opt-in. |
| load-delaydefault - | string | - | Set to idle to start the marketing tags after load and idle time or the first interaction. |
| posthog-keydefault - | string | - | PostHog project key. With posthog-host it starts PostHog: one page view per load, cookieless and anonymous without analytics consent, normal persistence with it. Set both or neither. |
| posthog-hostdefault - | string | - | PostHog ingest address, such as the absolute URL of a same-origin proxy path. |
| productdefault - | string | - | Product name registered on every PostHog event. Required with posthog-key. |
| surfacedefault - | string | - | Surface name registered on every PostHog event, such as website. Required with posthog-key. |
| environmentdefault - | string | - | Environment name registered on every PostHog event. Local sends nothing. |
| posthog-replaydefault false | bool | false | Records PostHog session replay, only with analytics consent. Every input and all text are masked. Needs posthog-key. |
| posthog-heatmapsdefault false | bool | false | Sends PostHog heatmap points, cookieless and anonymous without analytics consent. Needs posthog-key. |
| posthog-exceptionsdefault false | bool | false | Sends uncaught page errors to PostHog error tracking, cookieless and anonymous without analytics consent. Needs posthog-key. |
| posthog-web-vitalsdefault false | bool | false | Sends field Core Web Vitals (LCP, INP, CLS, FCP, TTFB) with the element, script and phase detail that traces a slow value to its cause, as $web_vitals events. Needs posthog-key. |
| posthog-web-vitals-sample-ratedefault 1 | double | 1 | Share of page loads that report, above 0 and at most 1. Needs posthog-web-vitals. |
| posthog-web-vitals-deploy-versiondefault - | string | - | Release identifier stored on every vitals event so a regression can be tied to a deploy. Needs posthog-web-vitals. |
With posthog-web-vitals on, the page's route pattern, such as /services/{slug}, is sent as page_template on every vitals event. It is the pattern, never the visitor's address.