Decide whether your site needs a page reload after each answer

Most sites need no reload, because TermsFeed Free Cookie Consent runs the scripts of an accepted category on the same page, the moment the visitor accepts. Turn on page_refresh_confirmation_buttons only when a declined or withdrawn category must stop at once, or when a script or your server reads the answer only while the page loads.

What page_refresh_confirmation_buttons does

With page_refresh_confirmation_buttons: true, a click on the "I agree", "I decline", or "Save my preferences" button reloads the page at once, and the reloaded page runs only the accepted categories. The "OK" button of implied consent reloads the page too. Opening the Preferences Center, switching its language, or closing it without saving reloads nothing.

Add the option to the object you pass to cookieconsent.run().

<script type="text/javascript" charset="UTF-8">
document.addEventListener('DOMContentLoaded', function () {
cookieconsent.run({
  "notice_banner_type": "headline",
  "consent_type": "express",
  "language": "en",
  "page_refresh_confirmation_buttons": true
});
});
</script>

The reload follows every answer, even a save that does not change any switch. Once an answer starts the reload, no tagged script runs on the page being left. Consent signals granted from scripts_specific_loaded therefore arrive on the reloaded page. The reload does not wait for responses, so send a consent record from user_consent_saved with navigator.sendBeacon() or fetch() with keepalive: true, or send it again on the reloaded page.

Without a reload, refusing or withdrawing does not stop tagged scripts that already run on the current page, such as a session recording tool or a chat widget. A script that reads the answer only at startup shows the old state until the next page load. A server that prints an embed or a tracking tag from cookie_consent_level sees a new answer only on the next request, which the reload sends at once. Read the cookie on the server with Read the Consent State.

What a reload clears: form input, scroll position, app state, and the referrer

A reload throws away what the visitor did on the page before answering: text typed into a form, the scroll position, and the state of a single-page app. Leave the reload off on pages where visitors type before they answer, such as a checkout, by printing false for page_refresh_confirmation_buttons in the template of those pages.

The reloaded page keeps its address, so campaign parameters such as utm_source survive. The referrer does not survive in Chrome, which sets the referrer of the reloaded page to its own address.

The checks assume express consent with page_load_consent_levels left out or at the generator value ["strictly-necessary"]. Turning on the reload takes 3 steps and about 10 minutes, and reopening the Preferences Center after the answer needs a cookie settings link on the page. Add one with Add a Cookie Settings Link.

  1. Add "page_refresh_confirmation_buttons": true to the configuration object, and deploy it.
  2. Close every private window and open a new one. Open Chrome DevTools on the Network tab and turn on the "Preserve log" checkbox. Type the host of an optional tagged script in the filter box, such as googletagmanager.com for a tagged Google tag, then load your site.
  3. Click the "I agree" button, confirm the page reloads, and confirm the requests to that host start only after the reload. Then open the Preferences Center with your cookie settings link, select the category tab of that script, and set its switch to Inactive. Click the "Save my preferences" button, and confirm no request to that host follows the second reload.