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. 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.
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.
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 }. 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, with double quotation marks around every key and every text value, and save again.
You can start again from the Customization settings instead: an empty field rebuilds the JSON from them, without the keys you added by hand.
- 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.
Configuration Parameters: "<parameter>" must be one of: <values>. The previous value was kept.
- Replace the value with one from the list in the error, in lower case, such as
"express"for"Express". - Click the "Save Changes" button.
You can set the same choice on the Customization tab instead of 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 text such as "hide". The error is the accepted-values message, with 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.
- Write
trueorfalsewithout quotation marks in place of the text. - Click the "Save Changes" button.
- Reload the tab and confirm the value.
Cause 4: "Callbacks" must be a JavaScript object
The Callbacks field, or the callbacks key of the Configuration Parameters, must hold a JavaScript object: the plugin saves other code but leaves it out of your WordPress website. Your website then runs the consent banner with no callbacks, so no Google Consent Mode update runs after consent either.
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.
Code that starts with a function, a statement, or a semicolon instead of { is not an object. Wrap the code in an object, or paste back the default Callbacks from Cookie Consent Callbacks in WordPress where 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 Callbacks are not valid JavaScript (<error>). They are left out of your website until they are corrected. Save anyway?
- Click the "Cancel" button, which stops the save and puts the cursor in the Callbacks field.
- Correct the syntax error the dialog names in brackets, such as a missing comma between 2 callbacks or a missing
}. - Click the "Save Changes" button again and confirm that no dialog opens.
The "OK" button saves the code, and the browser reports a SyntaxError. Click the link of the red SyntaxError line in the Console tab 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.
The Configuration Parameters are not valid JSON, so changes made here are not applied. Please correct them on the Configuration Parameters tab.
The page source then shows the script with the id termsfeed-autoterms-cookie-consent-script without a cookieconsent.run call. Correct the JSON on the Configuration Parameters tab with a JSON validator, or rebuild it 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. The entry stays in the form for you to correct.
- "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
An error that names unfiltered_html means your account does not save code or HTML. Fix it 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.
- 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.