Decide when each piece of vendor code runs

Each vendor in TermsFeed Privacy Consent has 16 vendor tag slots: 4 vendor tag types (JavaScript, HTML, Style, and Link), each with 4 trigger actions. A trigger action is the moment Privacy Consent inserts a vendor tag: on accept, on decline, on load permanent, or on load transient. The vendor tag type decides where the code goes, and the trigger action decides when. The custom vendor form shows the trigger actions as the switches "If allowed", "If declined", "On load (permanent)", and "On load (transient)". On accept and on decline follow the answer from the visitor, and the 2 on-load trigger actions ignore it.

The 16 vendor tag slots as a grid of the 4 vendor tag types against the 4 trigger actions: If allowed, If declined, On load (permanent), and On load (transient)

Trigger action Inserted Follows the answer Removed
On accept Once the vendor is allowed, on load and after each answer Yes Never in that page view
On decline Once a saved answer declines the vendor Yes From the vendor <div>, if the visitor accepts later in that page view
On load permanent Every page view, before any on-accept or on-decline vendor tag No Never
On load transient Every page view, before any on-accept or on-decline vendor tag No Once a saved answer exists, for any vendor

A vendor tag goes in at most once per page view, so answering again does not run it a second time.

Where each vendor tag type inserts its code

Vendor tag type Tab Where the code goes What to paste
JavaScript "JavaScript tags" <head> <script> elements, inline or with src
HTML "HTML content" Inside <div id="<vendor id>"> on your page Markup such as an iframe, a form, or an image
Style "Style tags" <head> <style> elements
Link "Link tags" <head> <link> elements, such as a web font stylesheet

JavaScript, Style, and Link vendor tags split the way a browser splits a page. Head elements go to <head>, and the first other element and everything after it go to the end of <body>. A <div> pasted after a <script> in a JavaScript vendor tag therefore lands at the end of <body>. In a JavaScript vendor tag, code outside a <script> element lands as text at the end of <body> and never runs, so the vendor form refuses it when you save.

An HTML vendor tag needs its <div> on your page: without it, Privacy Consent inserts nothing and prints nothing. Copy that <div> from the "Important tags" button on the row of the vendor. Before consent, the <div> of a vendor with on-accept HTML shows the embed placeholder.

Every inserted element carries the attribute termsfeed-pc1-vendor-tag-id. Its value is the vendor ID for an HTML vendor tag, and <vendor id>-javascript, <vendor id>-style, or <vendor id>-link for the others. Replaceable tags have no slot, and "Has replaceable tags?" is their only switch on the form. Privacy Consent fills a visitor placeholder such as @{TF_PC_V1_VISITOR_COUNTRY} in the code of every slot and every replaceable tag right before it inserts that code. Look up every placeholder in Visitor placeholders in vendor tag code.

The 16 vendor tag slots

The trigger actions behave the same way in every tab.

Slot Field on the form Typical use
JavaScript, on accept "JavaScript code to insert if allowed" Analytics and advertising scripts
JavaScript, on decline "JavaScript code to insert if declined" Code for decliners that does not set a cookie
JavaScript, on load permanent "JavaScript code to insert on load (permanent)" Code that needs no consent
JavaScript, on load transient "JavaScript code to insert on load (transient)" Code that matters only before an answer
HTML, on accept "HTML code to insert if allowed" An embedded video, map, or form
HTML, on decline "HTML code to insert if declined" A static image or a link in place of an embed
HTML, on load permanent "HTML code to insert on load (permanent)" A notice that stays next to the content
HTML, on load transient "HTML code to insert on load (transient)" A note shown until the visitor answers
Style, on accept "Style code to insert if allowed" CSS for the widget of the vendor
Style, on decline "Style code to insert if declined" CSS that hides the empty slot of the widget
Style, on load permanent "Style code to insert on load (permanent)" CSS that reserves space for the content
Style, on load transient "Style code to insert on load (transient)" Loading-state CSS
Link, on accept "Link code to insert if allowed" Web font and widget stylesheets
Link, on decline "Link code to insert if declined" A local font stylesheet
Link, on load permanent "Link code to insert on load (permanent)" A stylesheet from your own host
Link, on load transient "Link code to insert on load (transient)" A stylesheet needed only before an answer

An on-accept vendor tag runs when the vendor is allowed, on page load and right after an answer, with no page reload. A vendor is allowed when its vendor category or the vendor itself is on. The visitor turns it on with I Agree or Save Selection on the consent banner, or Save Preferences in the Privacy Preferences Center. I Agree and Accept this vendor in an embed placeholder do the same.

Essential vendors run their on-accept vendor tags on every page view with no answer. Under the opt-out model, where no consent banner shows, every other vendor runs them too until the visitor opts out. Find out which visits follow that model in Cookie Banner by Visitor Location.

A visitor who withdraws consent does not stop a vendor that already ran in that page view. Its on-accept content stays until the next page load, which applies the decline in full.

Paste JavaScript into an on-accept slot inside a <script> element. Find out what happens to code without one in Where each vendor tag type inserts its code.

On decline: the code replaces a refused service

An on-decline vendor tag runs only after a saved answer declines the vendor, on that page view and on later ones while the answer stands. It never runs before a first answer, so a visitor who ignores the consent banner does not get on-decline code. It does not run for a vendor added after the answer until the visitor answers again.

Use on decline for content that stands in for the service, such as a contact link in place of a chat widget. A vendor that ran earlier in the page view gets its on-decline tags at the next page load, so on decline does not run at the moment of a withdrawal. A visitor who accepts later in the page view gets the on-accept content at once, and the on-decline content leaves the vendor <div>. On-decline code in <head> stays until the next page load.

On load permanent: the code runs whatever the answer

An on-load permanent vendor tag runs on every page view for every visitor, with or without consent, and stays on the page. Use it only for code that does not contact a vendor host or set a cookie, such as CSS that reserves space for an embed. Reserve that space with Prevent Layout Shift.

Every on-accept and on-decline vendor tag waits for all on-load vendor tags, with no time limit. An on-load <script src> without async whose server never answers holds those tags for every vendor until the browser gives up on it. Add async to any external script you put in an on-load slot.

On load transient: the code leaves once an answer exists

An on-load transient vendor tag runs on every page view, and Privacy Consent removes it from the page once a saved answer exists. A first-time visitor keeps it until the first answer. Any saved answer counts, from the consent banner, the Privacy Preferences Center, or an embed placeholder, even one that accepts or declines another vendor. A returning visitor gets it inserted and removed in the same page view, so the content appears briefly.

Privacy Consent removes every node the vendor tag inserted, once its iframes, images, and stylesheet links have loaded or failed. An eager iframe or image that never finishes keeps its vendor tag on the page, and a script that ran is not undone.

Why a tracking script never goes in an on-load slot

A tracking script in either on-load slot runs before the visitor answers and for visitors who decline. The on-load transient slot is no exception, because the script has sent its requests and set its cookies by the time Privacy Consent removes the element.

Put every script that sets cookies or sends visitor data in an on-accept slot, then test a live site for this mistake in a new private window. Open the Chrome DevTools Network tab, filter for the vendor host, and click I Decline. A request to the host points to an on-load slot or a snippet left in the page. Trace it with the steps for a script that fires after a refusal.

The Google Analytics 4, Google Ads, and Google Tag Manager templates put the Google tag in the on-load permanent slot on purpose. Privacy Consent sends the Google Consent Mode v2 defaults before that slot runs, and the tag does not set a cookie before consent. Read about that setup in Set Up Google Consent Mode v2.

Which trigger action to use for your code

Use on accept for almost everything, and add the other 3 only for fallback content and layout. Most custom vendors need one vendor tag, JavaScript on accept.

Goal Slot Example
Load a tracking, advertising, or marketing script after consent JavaScript, on accept A chat or analytics snippet from the vendor
Load an embed after consent HTML, on accept, with the vendor <div> on your page An iframe or other embed markup
Load a web font or widget stylesheet after consent Link, on accept A <link> to a web font stylesheet
Style a vendor widget after consent Style, on accept A <style> block for the widget
Show an alternative to visitors who decline The matching type, on decline A contact link in place of a chat widget
Reserve space whatever the answer Style, on load permanent CSS with a min-height for a video slot
Show a message only until the visitor answers HTML, on load transient A note that the map loads after consent
React once, at the moment the visitor answers None: use a callback A call that stops your feature on withdrawal

An iframe or image that has to stay in your templates takes a replaceable tag instead of an HTML vendor tag. Compare the 2 methods with How Blocking Works.

A trigger action follows the consent state on each page view, so none of them fires once at the click. Run code at the moment of an answer with Run Code on Accept or Decline.

Confirm which vendor tags ran on a page. Open Chrome DevTools, select the Elements tab, and search for termsfeed-pc1-vendor-tag-id=. On-load transient elements carry data-termsfeed-pc1-vendor-transient= beside it while they stay on the page.

How vendor tags behave on repeat visits

Privacy Consent applies the stored answer on every page load, so a returning visitor runs the same vendor tags again on each page. These rows cover a non-essential vendor. An Essential vendor runs on accept in every row and never on decline.

Visit On accept On decline On load permanent On load transient
First visit, consent banner asks Does not run Does not run Runs Runs and stays
First visit, opt-out model Runs Does not run Runs Runs and stays
Returning visitor with an answer Runs if accepted Runs if declined Runs Runs, then removed once loaded
Vendor added after the answer Does not run Does not run Runs Removed once loaded

Privacy Consent does not delete cookies a vendor already set. An answer lasts 365 days (12 months) by default. Look up that period with Consent Expiry.

Saving an edited vendor tag reaches visitors within 1 hour. Pages already open keep the old code until they reload. Check the new code in a new private window: open the Elements tab of Chrome DevTools and search for termsfeed-pc1-vendor-tag-id=.

An edit that changes vendor tag code asks visitors who answered earlier to answer again. Read who is asked in Force Every Visitor to Consent Again.