Add the TermsFeed Privacy Consent cookie banner to a hand-coded site by pasting its snippet into the <head> of every page, directly before </head>. This guide fits plain HTML files and server templates you edit yourself, such as PHP includes or server-side includes. Setup takes about 10 minutes for a site with a shared header file, and it needs no plugin.

The consent banner asks before vendors run, which the ePrivacy Directive and the General Data Protection Regulation (GDPR) require for non-essential cookies in the EU. A site builder or framework has its own steps, so check the install catalog for your platform first.

Open your consent banner in the TermsFeed app, select Install, and click "Copy" under "Add the script to your website". The token in the address is the only part that differs between consent banners, so paste the copy from the app rather than typing it. A consent banner has to exist first, so make one with Create Your First TermsFeed Privacy Consent Banner.

<!-- Privacy Consent by TermsFeed (https://www.termsfeed.com) -->
<script type="text/javascript" src="https://cdn.termsfeedtag.com/plugins/pc/v1/YOUR_TOKEN/plugin.js" async></script>
<!-- End Privacy Consent by TermsFeed (https://www.termsfeed.com) -->

Paste the snippet before the closing head tag on every page

A page without the snippet does not show a consent banner or run a vendor, so every page a visitor opens needs it. A site with a shared header file needs one edit in that file (header.php, head.html, or an .shtml include). A site of separate HTML files needs the same edit in each file.

Here is a complete page with the snippet in place.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Example Page</title>
  <link rel="stylesheet" href="/css/site.css">

  <!-- Privacy Consent by TermsFeed (https://www.termsfeed.com) -->
  <script type="text/javascript" src="https://cdn.termsfeedtag.com/plugins/pc/v1/YOUR_TOKEN/plugin.js" async></script>
  <!-- End Privacy Consent by TermsFeed (https://www.termsfeed.com) -->
</head>
<body>
  <h1>Example Page</h1>
</body>
</html>

Keep the async attribute, which lets the page keep rendering while the script downloads. Keep the lang attribute on <html> too, since Privacy Consent reads it first to choose the language of the consent banner.

Google tags added from their templates in the TermsFeed app need no Consent Mode code in the head, because Privacy Consent sends the defaults before it loads them. The head then holds only the snippet, with no hand-pasted Consent Mode code.

Basic Consent Mode, with your own code, has a fixed order: the Consent Mode defaults, then any Google tag that stays in the page, then the Privacy Consent snippet. Google tags read the defaults when they start, so the defaults come first. This outline shows the position of each part. Copy the complete block from Set Up Google Consent Mode v2.

<head>
  <meta charset="utf-8">
  <title>Example Page</title>

  <!-- 1. Your Google Consent Mode v2 block: defaults and callbacks -->

  <!-- 2. Any Google tag or Google Tag Manager container that stays in the page -->

  <!-- 3. Privacy Consent by TermsFeed (https://www.termsfeed.com) -->
  <script type="text/javascript" src="https://cdn.termsfeedtag.com/plugins/pc/v1/YOUR_TOKEN/plugin.js" async></script>
  <!-- End Privacy Consent by TermsFeed (https://www.termsfeed.com) -->
</head>

Never load Privacy Consent from inside Google Tag Manager, because the container then decides when the consent banner appears. Choose how the 2 work together with Use Google Tag Manager.

Load the script from the address the app gives

Keep the src address as the app shows it, on cdn.termsfeedtag.com. TermsFeed updates the script at that address, so a copy you serve from your own server does not get updates. A proxy under the same path has to forward every Privacy Consent request with its Origin header, or the settings request fails and no consent banner appears. Read what a proxy changes in Install TermsFeed Privacy Consent on Netlify and Vercel or Install TermsFeed Privacy Consent on Cloudflare Pages.

Allow cdn.termsfeedtag.com in your Content Security Policy

A site that sends a Content Security Policy header must allow https://cdn.termsfeedtag.com in script-src and connect-src, and inline styles in style-src. Without those entries the browser blocks the script, the settings requests, or the consent banner styles, and the Console tab shows a "Refused to load" message. Copy the entries and the rules for vendor hosts from the Content Security Policy reference.

Move hand-pasted tracking code into vendors

A hand-coded site does not add tracking by itself, so every tracking script on it is a snippet someone pasted into your templates. Each of those runs before any answer while it stays in the page. Search your templates for googletagmanager.com, google-analytics.com, connect.facebook.net, clarity.ms, and hotjar.com to find them.

Move each one into a vendor in the TermsFeed app, then delete it from your templates. Set each tool up with Add a Vendor From a Template.

Add this element to the shared footer, beside your Privacy Policy link. A click on it opens the Preferences Center, and a <button> has no href, so the click never scrolls the page. Privacy Consent listens for this ID on elements added after the page loads too.

<button type="button" id="open_privacy_preferences_element">Privacy Preferences</button>

A site with US visitors adds a second element with the ID open_privacy_choices_element where the sticky "Your Privacy Choices" button is off. Choose between these and the floating buttons with Let Visitors Reopen Preferences.

Enter your domain under "What is your website domain?" on the Settings page, and any other domain under "Additional domains". The app stores www.example.com as example.com, and that entry covers www and every subdomain on the Analytics page. The consent banner loads only on the domains you add, so a domain missing from the list does not show it.

Each hostname keeps its own answer in the browser, so a visitor who moves from example.com to www.example.com sees the consent banner again. Redirect one form to the other to avoid that second question, and add other domains with Run One TermsFeed Privacy Consent Banner Across Several Domains.

Save and upload the changed files, then open a page over https:// in a private window, since a local file:/// page stops Privacy Consent before it loads. Every visitor gets the consent banner under Strict, the consent logic it starts on. Under Standard in Settings, a visitor in a US state goes without, so choose a test location from Cookie Banner by Visitor Location.

  1. Open Chrome DevTools, select the Network tab, type termsfeedtag in the filter box, and reload. 7 requests appear with status 200: plugin.js, plugin-2.js, plugin-r2.js, preferences-r2.js, vendors-r2.js, and settings.json twice.
  2. Select the second settings.json request and open Preview. The response holds "serviceable": true.
  3. Select the Console tab and reload. No line after [termsfeed] holds [ee] or [ww].
  4. Filter the Network tab for the host of a custom vendor, such as hotjar.com, and reload. No request appears before you answer.
  5. Filter for events.push and click I Agree. A new request with status 201 appears, which shows that the consent log received the answer.

Test I Decline after closing every private window and opening a new one, because private windows share storage while any stays open. Run the other checks with Check That Your TermsFeed Privacy Consent Installation Works.

Common mistakes on hand-coded sites

Most failed installations come from a page that misses the snippet or a tracking snippet that stays in the page.

  • The snippet sits on the home page only. Pages built from another template do not show the consent banner. Search every template for cdn.termsfeedtag.com/plugins/pc/v1/.
  • The old tracking snippet stays in the page. A Google Analytics or Meta Pixel snippet left in the header runs before any answer. Remove it once its vendor exists.
  • The snippet appears twice on a page. A header include plus a pasted copy prints [ee][205bde55] or [ee][1040992c] in the Console tab, and the second copy stops. Keep one copy.
  • The page is tested from the disk. A file:/// page has no hostname, so Privacy Consent stops and prints [ee][36de8955]. Serve the page from a local web server.
  • The script loads through Google Tag Manager. The consent banner then waits for the container. Put the snippet directly in the <head>.

Each [ee] or [ww] code names its cause. Find the fix in the Console Error Reference.