How I Solved the Issue with Termly CMS Integration
What is Termly CMS?
Termly is a popular content management system (CMS) designed to help businesses comply with privacy regulations, such as GDPR, CCPA, and other data protection laws. It provides tools like cookie consent banners, privacy policies, and terms and conditions, ensuring that businesses stay legally compliant in their operations. Many websites integrate Termly to manage user consent, but sometimes integrating this tool Having problems checking if Banner exists and giving error that it does not exist I analyzed the problem and found the error
The Issue: Plugins
In my case, The problem was because of the 10 Web Booster plugin because it increases the speed of the site and therefore the Termly bot does not see the Termly script because it is slow to load
The Solution: Excluding Termly Script from Performance Plugins
To resolve the issue, I decided to exclude Termly’s script from the performance-enhancing plugins. By doing this, I ensured that Termly’s JavaScript would load immediately when the page loads, without waiting for other scripts. The solution was straightforward but had a big impact on the performance of the website and the functionality of Termly.
Here’s how I did it:
- Identified the JS Delay Plugin: in my case is 10 web booster There are many components like WP Rocket or WP Optimizer or any other plugin you have installed that you know is delaying JavaScript.
- Excluded the Termly script: In my performance plugins, I added the Termly script to the exclusion list, ensuring it would not be delayed by the optimization plugins. This allowed the Termly banner to load right away without waiting for other JavaScript on the page to execute.
I have added in the section As shown in the picture above Excluded Js ” termly.io ” Because he sees a script that contains this word, he excludes it. From the delay and for you any additional component you use you can add the same thing
install the termly script steps :
It is better not to use the Termly plugin to add the script to the head section because there may be plugins that bypass it. I recommend adding a function in the theme’s function.php file. Add the following code:
function add_termly_script_via_javascript() {
?>
<script type="text/javascript">
(function() {
var termlyScript = document.createElement('script');
termlyScript.type = 'text/javascript';
termlyScript.src = 'https://app.termly.io/resource-blocker/YOUR-WEBSTE-UUID?autoBlock=on';
var head = document.getElementsByTagName('head')[0];
if (head) {
head.insertBefore(termlyScript, head.firstChild);
}
})();
</script>
<?php
}
add_action('wp_head', 'add_termly_script_via_javascript', 0);
Make sure to change the Termly script title to the one you get from Termly by clicking Install then select Plain HTML
and paste the link instead of https://app.termly.io/resource-blocker/YOUR-WEBSITE-UUID?autoBlock=on It is in the code above, so make sure to change it when adding the code.
Final
With these steps you can solve the verification problem now. Go to the Termly website and click on Scan Now and it will appear that it is installed.
If you have any questions, please feel free to ask.
Related Posts
how to createa free business email in 2 minutes or less
February 7, 2023
Best VPS Services
January 16, 2023