CookieYes helps you create a cookie banner in simple and easy steps. The first step you need to do is create an account with CookieYes, and enter the URL of your website. Then you will be provided with a script to be copied and placed in your website.
This article will help you understand how to correctly place the code in your website HTML, to display a cookie banner on your website front end. It is important to place the code within the <body>...</body> tags for the banner to be correctly displayed on the website.
Where to Place the Code in Your HTML?
To place the code into your HTML file, open your website code using a code editor. Now, let us see with an example how to add the script in the website HTML code. Below is the basic markup of an HTML file before adding the CookieYes script.
<html> <head> This is the head of your page. <title>Example HTML page</title> </head> <body> This is the body of your page. </body> </html>
Below is the same code after adding the script copied from CookieYes. The highlighted lines are the new lines of code added, just before the closing </body> tag.
Once you have inserted the code into the body section of the website and saved, there are no additional changes required and the cookie banner will appear on the front-end of your website.
If you are using a WordPress Website
If you are using a WordPress website, what you need to do is log in to your admin area of the website. There are two ways with which you can add the code to the body section of your WordPress website.
- Using a plugin that helps you insert code to the "body" section of your WordPress site.
- Make changes using the WordPress theme settings. It is not recommended to make changes directly to the theme header file as the changes made to this file will be overwritten when the theme is updated.
In the first method, you need to find plugins like Insert Headers and Footers to your WordPress website. Using a plugin will allow you to insert code into your WordPress website without having to edit the theme files. After you have installed the plugin, all you need to is to paste the code into the corresponding section of the plugin which inserts the code to the body section of the website. With this plugin, copying the code in the field "footer" will insert the code just before the closing </body> tag. Adding the code using a plugin also comes in handy in cases where the website theme doesn't allow directly editing the theme files.
Please note that the above-mentioned plugin is not recommended by us and is rather an example of a plugin that can help you achieve adding the script to your WordPress website.
In the second method, from the WordPress admin dashboard, navigate to Appearance > Editor. From the Editor page, head over to the Theme Header (header.php) file of your theme. From this file, add the code copied from CookieYes within the <body> tag and click on the Update File button.
After you have updated the file, go to the front-end of the website to see the banner displayed on the website.
Making Changes in the Consent Banner
If you need to make changes to the cookie banner or add new cookies or scripts to be blocked on the website, you can go to the dashboard of your CookieYes account and make the necessary changes. After installing the code, you will not have to update the code again to reflect the changes on your website. All you need to do is make the changes from CookieYes dashboard and save the changes.