Read what an error on saving the Cookie Consent kit means and fix the setting it names
Each error the Cookie Consent kit in TermsFeed AutoTerms shows on save names the setting that caused it and says what the plugin did with your change. Most errors keep the previous value, so the site runs as it did before the save. The Callbacks error and the "OK" button of the Callbacks syntax dialog are the exceptions: the plugin saves the code, but your WordPress website runs none of its callbacks. The errors appear at the top of the tab after you click the "Save Changes" button, and the vendor script alerts appear in a browser dialog.
Cause 1: "Configuration Parameters" must be a valid JSON object
The Configuration Parameters tab saves only a valid JSON object, so a typing error leaves the stored JSON as it was. The tab names the fault in general terms.
The Configuration Parameters tab shows this error.
Configuration Parameters must be a valid JSON object, for example {"website_name": "My website"}. Your changes were not saved.
The usual faults are a missing or extra comma, single quotation marks, a comment, or a missing }. JSON that is a list in square brackets instead of an object in curly brackets gives the same error. Paste the text of the field into any JSON validator, which names the line and the character of the fault.
Correct the fault the validator names, with double quotation marks around every key and every text value, and click the "Save Changes" button again.
Start again from the Customization settings if you prefer: an empty field rebuilds the JSON from them, without the keys you added by hand. Check every key in Cookie Banner JSON Settings in WordPress.
- Copy the keys you added by hand out of the field.
- Empty the field and click the "Save Changes" button.
- Add the copied keys back into the field and click the "Save Changes" button.
Cause 2: A parameter in the Configuration Parameters must be one of the accepted values
The parameters with a fixed list of values take only those values in lower case, so the plugin keeps the previous value of a parameter set to anything else. The plugin saves the rest of the JSON, and the error names the parameter and the values it accepts.
Read the error at the top of the Configuration Parameters tab once the save finishes.
Configuration Parameters: "<parameter>" must be one of: <values>. The previous value was kept.
Compare the value in your JSON with the values the error lists. A wrong value is missing from that list, or uses capitals such as "Express".
Put an accepted value in place of the wrong one.
- Replace the value with one from the list, in lower case.
- Click the "Save Changes" button.
Set the same choice on the Customization tab if you prefer a field to the JSON. Look up every parameter and its accepted values in Cookie Banner JSON Settings in WordPress.
Cause 3: A boolean parameter in the Configuration Parameters must be true or false
The 3 boolean parameters, which have no Customization field, take a boolean value, so the plugin keeps the previous value of one set to anything else. The error is the accepted-values message, with the name of that parameter and true, false as the accepted values.
The 3 parameters are notice_banner_reject_button_hide, preferences_center_close_button_hide, and page_refresh_confirmation_buttons. The plugin reads 1, 0, yes, no, on, and off as booleans too, and writes them back as true or false.
Find the parameter the error names in the JSON. The parameter holds text the plugin does not read as a boolean, such as "hide" or "maybe". An empty string saves as false.
Give the parameter a bare boolean.
- Write
trueorfalsewithout quotation marks. - Click the "Save Changes" button.
- Reload the tab and confirm the value.
Cause 4: "Callbacks" must be a JavaScript object
The Callbacks field must hold a JavaScript object: the plugin saves other code but leaves it out of your WordPress website. Your WordPress website then runs TermsFeed Free Cookie Consent 4.2.0 with no callbacks, so no Google Consent Mode update runs after consent either.
This error shows at the top of the Customization tab after the save.
Callbacks must be a JavaScript object enclosed in { and }, for example: { 'notice_banner_loaded': () => {} }. They are not used on your website until they are corrected.
Read the Callbacks field on the Customization tab. Code that starts with a function, a statement, or a semicolon instead of { is not an object.
Wrap your code in an object and save it again. Paste back the default Callbacks from Cookie Consent Callbacks in WordPress if you no longer need your own code.
- Wrap the callbacks in
{and}, with each callback name as a key. - Click the "Save Changes" button and confirm that the error is gone.
Cause 5: The callbacks are not valid JavaScript
The Customization tab checks the Callbacks before saving, and code that does not compile opens a confirmation dialog. The dialog opens in the browser as soon as you click the "Save Changes" button on the Customization tab.
The Callbacks are not valid JavaScript (<error>). They are left out of your website until they are corrected. Save anyway?
The text in brackets names the syntax error, such as a missing bracket. The "Cancel" button stops the save and puts the cursor in the Callbacks field. The "OK" button saves the code anyway.
Cancel the save and correct the code first.
- Click the "Cancel" button.
- Correct the syntax error the dialog names, such as a missing comma between 2 callbacks or a missing
}. - Click the "Save Changes" button again and confirm that no dialog opens.
Despite the dialog text, the plugin prints saved code with a syntax error, and the code then fails in the browser while the consent banner keeps running. The Console tab of the website then shows a red SyntaxError line; click its link to reach the script with the id termsfeed-autoterms-cookie-consent-callbacks.
Cause 6: The Customization tab says the "Configuration Parameters" are not valid JSON
The Customization tab warns you while the stored Configuration Parameters are invalid JSON, and its changes then do not reach any page. Your WordPress website does not show the consent banner or run any vendor script until you correct the JSON.
Read the warning on the Customization tab, which sends you to the Configuration Parameters tab for the correction.
The Configuration Parameters are not valid JSON, so changes made here are not applied. Please correct them on the Configuration Parameters tab.
Paste the text of the Configuration Parameters tab into a JSON validator, which names the fault. In the page source of your WordPress website, the script with the id termsfeed-autoterms-cookie-consent-script does not hold a cookieconsent.run call.
Correct the fault the validator names on the Configuration Parameters tab, or rebuild the JSON from the Customization settings. Follow the invalid JSON steps in WordPress Cookie Banner Not Appearing.
Cause 7: The "Add vendor script" button shows an alert
The Vendor Scripts tab refuses an incomplete entry or HTML code with no <script> tag, and shows an alert. Each alert names what is missing, and the entry stays in the form for you to correct.
Close the alert and read the Name, Type, and Script fields of the form. An empty field, Script code that starts with HTML and has no <script> tag, or a <script> tag with no closing </script> is the fault the alert names.
Match the text of the alert to its fix.
- "Please enter a Name for the vendor script." Type a name, such as Google Analytics.
- "Please select a Type for the vendor script." Choose 1 of the 4 categories.
- "Please enter Script code for the vendor script." Paste the vendor code.
- "Please enter the
<script>code of the vendor script. Other HTML, such as<noscript>or<img>, cannot wait for consent and is not added to your website." Paste only the<script>part of the code. - "A
<script>tag in the Script code has no closing</script>tag, so that script would not be added to your website. Please paste the complete code of the vendor script." Copy the code again, up to the last</script>.
Correct the field the alert names, click the "Add vendor script" button, then click the "Save Changes" button. Add each tool with Block WordPress Scripts Until Consent.
Cookie Consent kit errors that name the unfiltered_html capability
The messages that name the WordPress unfiltered_html capability come from the permissions of your account. The plugin keeps the previous code, or removes the HTML, for an account without that capability. Fix those errors with Code or HTML Not Saving in WordPress.
How to verify that the Cookie Consent kit settings saved
A clean save does not show an error at the top of the tab, keeps your value after a reload, and reaches your WordPress website. Follow the value from the tab to the page source.
- Click the "Save Changes" button and confirm that no error appears at the top of the tab.
- Reload the tab and confirm that your value is still there.
- Open the Customization tab and confirm that the Preview shows the consent banner with your settings.
- Clear the page cache, close every private window, and load your WordPress website in a new one. Open the page source with Ctrl+U (Cmd+Option+U on a Mac) and confirm that the script with the id
termsfeed-autoterms-cookie-consent-scriptholdscookieconsent.run(config). - Open the Console tab and confirm that no red line names
cookie-consent.jsorcookieconsent, and that the source link of noSyntaxErroropens the scripttermsfeed-autoterms-cookie-consent-callbacks.