Real cookie banner tutorial - WordPress cookie banner
Tags: wordpress, tutorial, webdev, gdpr
Published: 2023-01-28 15:55:13

Today width GDRP/DSGVO it is very important that your web page doesn't do any external request like showing a YouTube video or adding analytic scripts without the consents of the user!

In this small tutorial I show you how to use the WordPress Plugin [Real Cookie Banner](https://devowl.io/lAWmsqLD/) to add a simple cookie banner and block external content.

> The plug-in is free for normal usage but if you buy it make sure to use the code `MIGAWEB` for 20% in the first year! Go to [Real Cookie Banner](https://devowl.io/lAWmsqLD/) and use the code `MIGAWEB` in the checkout page. 

## Topics

* [Install](#installation)
* [Enable the plugin](#enable-the-plugin)
* [Block external content](#block-external-content)
* [Final words](#final-words)
* [Get the plugin](https://devowl.io/lAWmsqLD/)

## Installation

The first step is to install the plugin in your WordPress page. Go to "Plugins - Add new" and search for "[Real Cookie Banner](https://devowl.io/lAWmsqLD/)". Install this plugin and activate it:

![install](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/08sbxfk8judcv0jbv1po.png)

After you activate it you have a new menu entry called "Cookies" in you WordPress menu and it will show you the "First start" page.

![first_start](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kza9dkkpduhg1r0z914v.png)

Click on "Start configuration" and in the next popup we simply use the "Continue without any support..." link below the button.

![activate](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6li5chhe5k464u6n0lu3.png)

If you want to keep updates for the plugin you'll click the blue button with the first item selected.

After that you will see the main menu of the plugin:

![main_menu](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xyf524l5gl9t661yryok.png)


## Enable the plugin

If you go and open the front-end of your page you won't see any cookie banner yet. We need to active it first. 
In your back-end go to "Cookie" and select the "Settings" tab.

![settings1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ycgdm4ythay4ibh8dasu.png)

Here you have to switch on the "Cookie Banner/Dialog" and press "save settings" at the bottom.

![settings2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f5g7vdalxa520067z9t4.png)

Now when you go to your front-end it will show you the cookie banner:

![banner](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n5u3xl2xzmwq0dpwnmle.png)


## Block external content

At this point we can add some functionality to cookie banner. For this tutorial we add a YouTube blocker that won't make an external connection unless the user accepts the cookie banner or clicks on the button that is presented instead of the video.

Create a page with a simple YouTube video:

![yt](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ucr7t7vwif7hm88hxol1.png)

It will show the player and if you look at the DevTools - Network tab you will see many external connections to YouTube.

To block those you go to the "Cookies - Content Blocker" tab and press the "Add content blocker" button:

![content_blocker](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7vt15gs3o7kaq14y7twg.png)

[Real Cookie Banner](https://devowl.io/lAWmsqLD/) will present you a whole list of templates you can chose from:

![templates](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/go0hdv10tvak3vagciv8.png)

One advantage of the [pro version](https://devowl.io/lAWmsqLD/) is that you can select all of them which saves you a lot of time creating each of the from scratch!
The YouTube content blocker is available in the free version! So search for "youtube" and click on the icon:

![yt](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n7vdk3gcok6d7i2z2758.png)

After that it will show you the blocker configuration:

![yt2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dqomr0rrenmk8meo1agb.png)

UI configuration

![yt3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jw2ga1cbikta8hbr7sna.png)

In the "Description field" you can add a text that will be visible in the box when the video is blocked. Use this text to inform the user why he/she wants to click and allow the content.

On setting we will need to add is the "Connected services" section in this screen. Scroll to:

![yt4]https://dev-to-uploads.s3.amazonaws.com/uploads/articles/twg3elaym5on9nw4j09r.png)

and again: click the preset "YouTube - Create now".
This will show you another configuration popup with prefilled data.

![function](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qodgpuld2xm0o339lvbg.png)

Those items will be visible later in the "individual settings" of the cookie banner and here you can set the "group" under which the cookie will be visible (e.g. functional cookies, marketing cookies, analytic cookies,...). Keep everything as it is and save it.

<b>That's it!</b>

![done](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7uqg4geapw3aocisayak.png)

Now when you visit your test page you can see that the video is blocked behind the cookie banner

![blocked](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/snebllwum8mqgr11pvgb.png)

And if you dismiss that you can see the blocker box instead of the player:

![blocker](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4d3wtras1xozcilhtacl.png)

and no external request is made before you active that!

If you look at the "individual settings" in the cookie banner you will find the "Functional - YouTube" entry:

![individual settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ug7844mz7az41bqdpvh0.png)

## Final words

As you can see it is very quick and easy to block external content. You can do the same for other external elements you add into your page like Calendy, Facebook posts, Google maps or more. To use those templates you have to buy the pro version. Go to [Real Cookie Banner](https://devowl.io/lAWmsqLD/) and use the code `MIGAWEB` in the checkout page for a 20% discount in the first year. 
If you want to use the free version you can still block those items but you have to click "create from scratch" button

![scratch](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/brxd30bpn3t3bx670mmc.png)

and fill out the form yourself.

Make sure to follow for more tutorials on [Real Cookie Banner](https://devowl.io/lAWmsqLD/), WordPress, Elementor or app development with Titanium SDK.