WordPress GDPR - GreenGeeks https://www.greengeeks.com/tutorials/category/wordpress-gdpr/ How-to Website Tutorials Fri, 19 Aug 2022 17:55:08 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.3 How to Add the GDPR Cookie Consent Plugin for WordPress https://www.greengeeks.com/tutorials/add-gdpr-cookie-consent-wordpress/ https://www.greengeeks.com/tutorials/add-gdpr-cookie-consent-wordpress/#comments Thu, 02 Jul 2020 16:08:33 +0000 https://www.greengeeks.com/tutorials/?post_type=ht_kb&p=35600 It’s very rare to visit a website in 2020 and not be asked to accept that the site utilizes cookies. And there is a great […]

The post How to Add the GDPR Cookie Consent Plugin for WordPress appeared first on GreenGeeks.

]]>
It’s very rare to visit a website in 2020 and not be asked to accept that the site utilizes cookies. And there is a great reason for this. The GDPR requires cookie consent from visitors. Cookies collect visitor information and GDPR was created to protect that information.

Unfortunately, there is no built-in WordPress cookie notice. Thus, you will have to add them via a plugin.

Today, I will demonstrate how to do so with the GDPR Cookie Consent plugin.

What Is GDPR?

The General Data Protection Regulation (or GDPR) is European legislation that is intended to protect user data in the EU. It protects all data collected from anyone in the EU. While this may sound like something that only applies in Europe, it is not.

It affects every website regardless of the country they originate from.

If you collect data and happen to collect information from a resident of the EU, you can face a fine of 20 million Euros ($24 million dollars).

Thus even if you do not market or do business in the EU, this legislation will force you to change the way you collect information.

How to Use GDPR Cookie Consent

The GDPR Cookie Consent plugin leaves nothing to the imagination with its name. It has one function and that is to ask visitors to consent. However, the plugin has a lot of customization options that help it blend in with your website’s design.

Note: Simply installing this plugin does not make your website GDPR compliant. It has multiple configurations, and you need to select the one that applies to your website. After all, there are many cookies that websites can use.

Step 1: Install the GDPR Cookie Consent Plugin

Let’s start by clicking on Plugins and selecting the Add New option on the left-hand admin panel.

Add New

Search for GDPR Cookie Consent in the available search box. This will pull up additional plugins that you may find helpful.

GDPR Cookie Consent

Scroll down until you find the GDPR Cookie Consent plugin and click on the “Install Now” button and activate the plugin for use.

Install Now

Step 2: Modify the Plugin Settings

On the left-hand admin panel, click on GDPR Cookie Consent and select the Cookie Law Settings option.

Cookie Law Settings

Here you will find all of the general settings of the plugin, which also include cosmetic changes like colors.

It is divided into 5 tabs.

General

The first option in the section is if the cookie bar is currently on or off. By default, it is on and should remain that way. If it is off, you are not asking visitors if they consent.

This is followed by what type of appearance the cookie bar will take. There are three options, a banner, popup, or widget. Select which one you want to use.

Cookie Bar Type

Underneath this, you can select where you want it to appear. The options you see are dependent on the last choice you made.

Cookie Bar Location

The rest of the options in this section deal with how the cookie bar will behave. Carefully go through and select the ones that work for you. Click on the “Update Settings” button when you are complete.

Update Settings

Customise Cookie Bar

This tab is about customizing the message of the cookie bar. I would recommend leaving it at the default value because if you misword it or fail to explain something properly, you could run into problems.

You also have an option to change the color of the bar and the text color.

Color Options

I recommend picking the same colors you use on your website for each. This helps the cookie bar look like its a normal part of your website. You can also pick the font, which I again recommend matching the font used by your theme.

Remember to save the changes when you are done.

Customise Buttons

The plugin comes with 4 buttons and you can customize each one. This includes, what they say, the color of the button and text, size of the button, and more.

Button Options

I recommend making sure all of the buttons follow the color and text font of your entire website.

Save the settings when you are done.

Advanced

The advanced tab only has one option, to delete all settings and reset it. If you ever need to do that, this is the place to do so.

Help Guide

Here, you will find a list of shortcodes and the margins of the buttons. There are also helpful links that will help you understand how the plugin works.

Entering Cookies

This is where you can enter all of your cookies. Simply click on the “Add New” button and add all of the information.

Policy Generator

If you click on the Policy Generator option, you will see all of the default messages the plugin generates. Again, feel free to change these, but it is recommended to leave the messages as is.

Changing what they say can lead to mistakes, although there may be special circumstances where a change is necessary. There is also an Add New option if you need to add additional messages, but again, this is very rare.

Non-necessary Cookie

This section allows you to ask for consent on cookies that are not necessary for your website. Again, if they collect information, you need consent. This is enabled by default and can be ignored unless you would like to change the message.

Necessary Cookie & Privacy Overview

This is a message that appears when a cookie is absolutely necessary for your website to run, but does not store it. There is nothing to do here except change the message.

The same can be said for the Privacy Overview. It is simply the message which explains the policy. Change this if you so desire.

Step 3: View It On Your Website

That covers all of the settings. The only thing left to do is actually see it in action. When you visit the website, you should see the cookie consent GDPR notification in the position you selected.

Cookie Consent

If you are unhappy with the appearance, simply go back into the settings and change them.

Congratulations on setting up the GDPR Cookie Consent plugin and complying with EU guidelines.

Why Do I Need to Ask Visitors to Consent to Cookies?

Cookies are small pieces of information that store personal information from visitors.

For example, if you went to an online shop and added something to the cart, that information would be stored as a cookie. The next time you visit that website, the item will still be in the cart. They are intended to save you time.

However, the GDPR protects all user information, this includes things that are commonly stored in cookies. The legislation requires that all websites ask the visitor if they are okay with the website collecting this data.

This is why when you visit most websites for the first time, you must agree to allow cookies.

Better Safe Than Sorry

The ridiculously high fines associated with GDPR compliance violations are no joke. They will end any website that isn’t from a large corporation. Luckily, it is rather easy to comply, but it does require some work.

Unfortunately, even though the law was put in place in 2018, WordPress has not created built-in functions to help you stay compliant. Instead, you must rely on a cookie notice plugin like this.

Do you think WordPress should have built-in tools for GDPR compliance? Did you find the plugin easy to use?

The post How to Add the GDPR Cookie Consent Plugin for WordPress appeared first on GreenGeeks.

]]>
https://www.greengeeks.com/tutorials/add-gdpr-cookie-consent-wordpress/feed/ 1
How to Set Up a Google Opt-Out Function in WordPress https://www.greengeeks.com/tutorials/google-opt-out-function-wordpress/ https://www.greengeeks.com/tutorials/google-opt-out-function-wordpress/#respond Mon, 23 Dec 2019 15:00:30 +0000 https://www.greengeeks.com/tutorials/?post_type=ht_kb&p=31453 What is a Google opt-out, and why might you need to provide it? Websites track visitors in a number of ways. Even if you aren’t […]

The post How to Set Up a Google Opt-Out Function in WordPress appeared first on GreenGeeks.

]]>
What is a Google opt-out, and why might you need to provide it?

Websites track visitors in a number of ways. Even if you aren’t using a stats program like Google Analytics, your web server keeps visitor logs. And if you do any affiliate advertising or remarketing, your visitors are being tracked.

In 2018, the European Union enacted a law called General Data Protection Regulation, or GDPR, that provided privacy laws for the residents of all EU member states. Among other things, the GDPR allows EU residents the “right to be forgotten,” which means if someone from the EU asks you to remove any data related to them from your site, you have to comply with the request or face fines.

If Users Can’t Register or Upload Data to My Site, Does GDPR Affect Me?

If you collect visitor browsing data through server logs or Google Analytics, GDPR rules require that you provide visitors with an analytics opt-out method to avoid being tracked. So yes, GDPR can apply to you even if your site doesn’t accept any user input.

Today, we’re going to talk about Google Analytics in particular since it is used by so many websites. Fortunately, it’s easy to comply with GDPR with the Google Analytics Opt-Out plugin. Let’s get it set up on your WordPress site and take a look at how it works.

It’s worth noting that the opt-out method used by this plugin is browser-dependent. So a user may opt-out of data collection on your site in one browser, but if they visit in another browser, they will be given the option to opt-out again.

Installing the Google Analytics Opt-Out Plugin

Log in to your WordPress admin panel.

In the left column navigation, mouse over the “Plugins” link and click the “Add New” link.

mouse over the "Plugins" link and click the "Add New" link

In the “Search plugins…” box, enter “Google Analytics Opt-Out.”

search for the WordPress Google Analytics Opt-Out plugin

Once you have located the plugin, click the “Install Now” button.

click to install the WordPress Google Analytics Opt-Out plugin

Click the “Activate” button.

click to activate the WordPress Google Analytics Opt-Out plugin

Configuring Google Analytics Opt-Out

In the left column navigation, mouse over the “Settings” link and click the “Analytics Opt-Out” link.

click the "Analytics Opt-Out" link

To activate the opt-out plugin, enter your Google Analytics code in the “UA- or GA-Code” field. The Analytics code is in the format UA-12345678-9. You can find it in your Google Analytics dashboard.

Check the “Show Editor button (Classic Editor)” box.

Update the “Opt-Out Successful” text if you’d like.

Click the “Save Changes” button.

enter your Google Analytics code

Adding the Google Opt-Out Option to a Page or Post With the WordPress Gutenberg Editor

Click the “add block” icon.

click the "add block" icon

In the “Widgets” section, click the “Analytics Opt Out” block.

click the "Analytics Opt Out" block

Enter the text you want to use for the opt-out link and update the page or post.

enter the text for the opt-out link

Now the opt-out link appears on the page.

opt-out link on the page

When a visitor clicks the link, they’ll get a confirmation pop-up.

confirmation pop-up

If you think you may want to use the banner to put a link on every page, don’t click the opt-out link yourself. If you do, you’ll have to open another browser to see the banner to configure it.

Adding the Google Opt-Out Option to a Page or Post With the “Classic” WordPress Editor

Open up a page or post in the editor, and you’ll see an opt-out link icon.

Click it to add the shortcode for the opt-out link to the page or post. You can change the link text in the shortcode.

shortcode inserted

Save the edit, and the link will appear on the page.

opt-out link on the page

To Automatically Add an Opt-Out Banner to Every Page of Your Site

If you want an opt-out banner to appear on every page of your site, go back to the “Analytics Opt-Out” section in the “Settings” section of your WordPress admin panel.

Check the “Use Banner” box. That will open up some new options.

click the "Use Banner" box

Opt-Out Banner-Text – enter your opt-out text here. The plugin automatically creates a link with the text, “Click here to opt-out,” so any text you enter here will appear before that link.

Integrate Shortcode – check this box.

Hide banner after closing – check this box if you want the notice to disappear entirely after a visitor clicks the opt-out link.

The plugin documentation says that an “info-button will be fixed to the bottom-right” of the page if you don’t check the box, but I didn’t find that to be the case.

options in the "Use Banner" box

Custom CSS – by default, the banner is blue with white text (see below). You can use CSS here to integrate the banner with your site design. The CSS class for the banner is “gaoop.” So for example, if you wanted to make the banner background light grey and the text and link black, you would enter this in the “Custom CSS” field:

.gaoop {
    color: #000000;
    background-color: #ECECEC;
}
.gaoop a {
    color: #000000;
}

When you’ve made your adjustments, click the “Save Changes” button.

Now a banner should appear at the bottom of each page of your site.

opt-out banner on site

What Happens if You Uninstall the Plugin

Uninstalling the plugin will have no effect on your site if you only used the site-wide banner and didn’t insert the opt-out shortcode on any pages or posts.

If you inserted the opt-out shortcode using the Gutenberg editor, the opt-out links will still be on the pages or posts, but clicking the link won’t do anything.

dead opt-out link on site

If you inserted the opt-out shortcode using the “classic” editor, the opt-out link shortcode will be displayed on the pages or posts.

opt-out shortcode on site

So if you used the shortcode on any posts or pages, regardless of the editor you used, you’ll have edit the content to remove the link or shortcode.

Do I Really Have to Worry About Complying With GDPR Rules?

I’m not a lawyer, so I can’t give you legal advice. Having said that, if your site doesn’t operate in the EU or serve visitors from the EU, and you don’t accept visitor input (that includes comments), you probably aren’t in danger of running afoul of GDPR. But realistically, you can’t prevent a resident of the EU from visiting your site, so the laws effectively cover every site on the internet.

Have you taken any steps to comply with GDPR rules? Do you use a different GDPR plugin on your WordPress site? Let me know in the comments.

The post How to Set Up a Google Opt-Out Function in WordPress appeared first on GreenGeeks.

]]>
https://www.greengeeks.com/tutorials/google-opt-out-function-wordpress/feed/ 0
How to Add GDPR Compliant Share Buttons to WordPress https://www.greengeeks.com/tutorials/add-gdpr-compliant-share-buttons-wordpress/ https://www.greengeeks.com/tutorials/add-gdpr-compliant-share-buttons-wordpress/#respond Fri, 13 Sep 2019 14:00:55 +0000 https://www.greengeeks.com/tutorials/?post_type=ht_kb&p=29193 A lot has been made over the General Protection Data Regulation (GDPR) law that the European Union put out some time ago. This has caused […]

The post How to Add GDPR Compliant Share Buttons to WordPress appeared first on GreenGeeks.

]]>
A lot has been made over the General Protection Data Regulation (GDPR) law that the European Union put out some time ago. This has caused website owners to overhaul a number of parts on their sites, including having to create GDPR compliant share buttons.

GDPR and how it pertains to your site will vary, as each site has different standards they need to abide by. From plugins to terms of service and the way websites track data, updates had to be made across the board

Since GDPR has become a major issue, there are all kinds of plugin updates that may need to be done to make a website totally GDPR compliant. WordPress has done an impressive job of presenting ways to comply. This includes giving you ways to create custom share buttons that are compliant with GDPR standards.

What is GDPR?

The General Data Protection Regulation (EU) 2016/679 (GDPR) is a regulation in EU law on data protection and privacy for all individual citizens of the European Union and the European Economic Area.

It also addresses the transfer of personal data outside the EU and EEA areas.

The main goal of the law is to give control to individuals over their personal data. The law is vast and complex but does aim to protect people from the perils of being online.

Failure to comply with the law has very harsh punishments. A website that is not compliant can face a fine of up to 20 million Euros ($24 million dollars) or 4% of global annual turnover, whichever is higher.

With all of that in place, let’s take a look at a fantastic plugin that you can use on your website to add GDPR complaint share buttons to WordPress.

Shariff Wrapper

Shariff wrapper plugin

Shariff Wrapper is a social share WordPress plugin that gives you the ability to add GDPR compliant share buttons to your website. A German computer magazine developed “Shariff,” that follows the General Data Protection Regulation (GDPR – Regulation (EU) 2016/679). This plugin adapts the Shariff concept and provides an easy-to-use solution for WordPress.

So you know you are automatically covered as far as GDPR standards go when people use the Shariff WordPress plugin. This social plugin supports 32 services in 25 languages.

Basically, it comes with everything you need to be compliant and requires almost no work to set up. Let’s use this WordPress social share plugin to add our buttons.

Add GDPR Compliant Buttons

Step 1: Install and Activate the Plugin

In order to add GDPR compliant share buttons to your website, you need to install and activate the Shariff Wrapper plugin. You can do this in the admin dashboard of your WordPress website.

Install and activate gdpr compliant share buttons

Use the available search field and search the plugin by name. Once you see it pop up, install and activate it from there.

Step 2: Access the Main Settings Page

Once the plugin has been installed and activated, click on Settings > Shariff. This is located on the left menu of your admin area. Doing so will take you to the configuration page for the plugin.

Click settings then shariff

You can see that this option is now available in the menu because you successfully activated the plugin.

Step 3: Configure the Plugin

You can configure your custom share buttons however you would like. That being said, let’s take a look at a few items you will see on the configuration page of this social plugin for WordPress.

When you get on the page, you will see 7 tabs. These include:

  • Basic
  • Design
  • Advanced
  • Statistic
  • Help
  • Status
  • Ranking

Basic

This is where you will set up the share services you want to include. You also pick the areas of the site you want the GDPR complaint share buttons to be included, i.e. posts, pages, products.

Basic settings tab

Design

This area is where you can design the layout, look, and functionality of your custom share buttons for your website. This includes things like button language, size, padding, colors, and overall feel.

I recommend testing how the options look on your website before making a final decision.

Button design options

Advanced

Setup the advanced options for specific services you may be using here. Custom links, usernames, and IDs can all be configured.

Advanced options for gdpr compliant share buttons

Statistic

This area and its settings determine how Shariff handles share counts. Set them up how you would like.

Statistic tab

Help

The help tab provides you with some helpful information and links to resources. This is good for troubleshooting and set up when needed.

Help tab for Shariff

Status

This shows you the status of the plugin and lets you know if everything is working.

Status tab

Ranking

The Shariff WordPress plugin ranks all your most popular posts and pages. You can see all those stats here.

Ranking for gdpr compliant share buttons

Once you have set everything up how you like, you are ready to roll. You will see the share buttons showing and configured properly on the front end of your website.

Note: you can also use the shortcode [shariff] to manually put buttons on other places on your website.

Congratulations on setting up the Shariff and ensuring that your social share buttons are GDPR compliant.

Other Plugins to Consider

WordPress has built up a large library of plugins over the years, so it shouldn’t come as a surprise to learn that there are a lot of other options to choose from.

WordPress Social Sharing Plugin

WordPress-Social-Sharing

The WordPress Social Sharing Plugin is one of the best at adding GDPR compliant social share buttons to WordPress. It supports over 100 social icons including the major ones like Facebook, Twitter, Instagram, LinkedIn, Pinterest, Reddit, etc., and allows you to customize their appearance.

The customization options are more robust than Shariff, so if you were looking for more options, this is the plugin to try.

Social Sharing Buttons

Social Sharing Buttons

The Social Sharing Buttons plugin can help you easily add social buttons to WordPress while remaining GDPR compliant. This plugin even mentions that it uses the same design concept as Shariff to ensure it is in line with GDPR compliance. It supports all of the major social networks and provides different customization options.

Does GDPR Affect Me?

One of the most confusing points about GDPR is determining if it affects you.

For example, what if you own a restaurant and have a website with store hours, menu, and the ability to order online in the US? Clearly, you are not targeting someone in the EU. However, you may still need to be compliant.

This is because someone from the EU could still visit your website. And while that may sound ridiculous as a local small business owner, it does happen. GDPR covers all EU residents, so in this case, you could be penalized if you actually collect their data.

Thus, regardless of if you have any actual intention of doing business with someone from the EU, you most certainly need to be compliant if you are collecting personal information.

There are exceptions to this, but determining if you are an exception versus just being GDPR compliant, is not worth the trouble.

Thus, I strongly recommend not taking the chance and being GDPR compliant from the start.

Final Thoughts

Since the GDPR has become such a huge deal over time, it is important that you make sure your website is compliant with its standards. One way to do this is by adding GDPR compliant share buttons.

Now, you can quickly and easily do this without having to worry about it in the future. This prevents you from running into crippling fines later on if your website grows much faster than anticipated.

Remember it’s always better to err on the side of safety when it comes to your website.

Have you started to update your WordPress website to be GDPR compliant? What other GDPR social sharing plugins for WordPress are you using to help?

The post How to Add GDPR Compliant Share Buttons to WordPress appeared first on GreenGeeks.

]]>
https://www.greengeeks.com/tutorials/add-gdpr-compliant-share-buttons-wordpress/feed/ 0
How to Add a Checkbox in WordPress Comments for GDPR Compliance https://www.greengeeks.com/tutorials/add-a-checkbox-in-wordpress-comments-for-gdpr-compliance/ https://www.greengeeks.com/tutorials/add-a-checkbox-in-wordpress-comments-for-gdpr-compliance/#comments Mon, 11 Feb 2019 16:00:21 +0000 https://www.greengeeks.com/tutorials/?post_type=ht_kb&p=23663 In 2018, the European Union passed the GDPR law which requires consent for storing personal information. This includes any tracking cookies used in comment forms. […]

The post How to Add a Checkbox in WordPress Comments for GDPR Compliance appeared first on GreenGeeks.

]]>
In 2018, the European Union passed the GDPR law which requires consent for storing personal information. This includes any tracking cookies used in comment forms.

Thus, every website that has visitors in the EU needs to add a checkbox to WordPress comments for GDPR compliance.

And although this might sound like a pain, it’s actually quite simple. The checkbox was actually added in WordPress 5.4, and it is available on every installation.

In this tutorial, I’ll show you the easiest methods to add the checkbox to WordPress comments for the GDPR law.

Does Every Website Need To Be GDPR Compliant?

I know what you’re thinking, I run a website in the United States, this doesn’t apply to me. Wrong.

Even US websites are subject to this law if you collect any personal information from a citizen of the EU. All it takes is for an EU resident to use a VPN to visit your site and you could be subject to the penalties of the GDPR law.

So, yeah, every website should be compliant with the GDPR. The good news is that this has gotten much easier over the years. And that’s because everything you use is probably already GDPR compliant.

Platforms like WordPress have taken steps to rollout GDPR compliant features like what we are about to talk about.

How to Add A GDPR Checkbox for Comments

Step 1: Go to Discussion Settings

I am not exaggerating when I say this will take less than a minute to implement.

On the left-hand admin panel, click on Settings and select the Discussion option.

Click on Discussion settings to add a GDPR compliant checkbox to your comments section

Step 2: Check the Box for Cookies to be Set

Next, you just need to check a box to enable the feature in your comments section.

Locate the “Other Comment Settings” section. Check the “Show comments cookies opt-in checkbox, allowing comment author cookies to be set” checkbox.

Check the box

And that’s it. Scroll down to the bottom and click on the “Save Changes” button to finish.

Save the Changes

Congratulations on making your comment section GDPR compliant. However, this doesn’t mean your website is completely GDPR compliant. You have a lot of other stuff to do. Be sure to check out our other guides to become GDPR compliant.

Other Plugins to Add GDPR Checkbox For Comments

While WordPress provides a built-in way to make your comment section GDPR compliant, there are a number of plugins that may be useful in making your entire website compliant.

Here are a few plugins that will help not only your comment section be compliant, but your entire website.

Complianz can help add a checkbox to your comments section that is GDPR compliant

Complainz is a comprehensive cookie consent plugin that provides full coverage for your website. You can customize which regions to ask for cookie consent. This lets you not bother users that are not from the EU.

It also gives you the ability to block cookies that come from third-party tools. While most are compliant with GDPR, some are not. Thus, until you can confirm, blocking them is the safer option.

GDPR Cookie Compliance

GDPR Cookie Compliance is another all-in-one cookie consent plugin. What really separates this one from the rest of these kinds of plugins is its style.

Users have a lot more options to play around with, which is why it has over 200,000 active installs.

Outside of this, the plugin covers all of the cookie consent basics and it’s pretty easy to use. It’s a great choice for any website looking to be compliant with GDPR.

CookieYes | GDPR Cookie Consent & Compliance Notice

CookieYes

The CookieYes plugin is an all-in-one GDPR cookie compliance plugin for WordPress. The main focus is to ask users if they will accept your cookies. You can fully customize these notices, so they will always match your website.

While the main focus is GDPR, it’s worth noting that it also supports a variety of other internet-related laws from around the world. These include CCPA, LGPD, DSGVO, and more.

Make Your Comment Section GDPR Compliant Today With A Checkbox

Over the years, GDPR has only gotten stronger and there are no signs of it ever going away. Thus, ensuring your website is compliant is mandatory in 2022. But the good news is that it’s become really easy as WordPress has many built-in features for compliance.

Not only this, but third-party tools all have to be compliant as well. Otherwise, they wouldn’t be usable within the EU.

While it doesn’t take much to be compliant, not doing so could be catastrophic.

Do you use any other plugins to stay GDPR compliant? Does your website operate in a global setting?

The post How to Add a Checkbox in WordPress Comments for GDPR Compliance appeared first on GreenGeeks.

]]>
https://www.greengeeks.com/tutorials/add-a-checkbox-in-wordpress-comments-for-gdpr-compliance/feed/ 2
How to Manage Cookies in WordPress https://www.greengeeks.com/tutorials/manage-cookies-in-wordpress/ https://www.greengeeks.com/tutorials/manage-cookies-in-wordpress/#respond Thu, 27 Dec 2018 15:00:39 +0000 https://www.greengeeks.com/tutorials/?post_type=ht_kb&p=21121 Are you looking to learn how to manage your WordPress cookies? No, I do not mean the cookies that you eat. Cookies store temporary information […]

The post How to Manage Cookies in WordPress appeared first on GreenGeeks.

]]>
Are you looking to learn how to manage your WordPress cookies? No, I do not mean the cookies that you eat. Cookies store temporary information in the visitor’s browser and then they are called upon to improve the experience. Cookies are responsible for some personalization and behavioral targeting aspects on the website.

Many plugins also use cookies to store information that is needed to work properly. Cookies are used on almost every single website and are an essential part of running a website. Unfortunately, they are very hard to understand and will require some prior coding knowledge. Today, I will demonstrate how to manage cookies in WordPress.

What Exactly is a Cookie?

Most people will immediately think of their favorite type of cookie, but again that is the wrong kind of cookie.

The cookies web developers talk about are plain text files stored inside of a visitor’s browser. They have multiple uses that make them an essential part of any website. Here are some of the most important things cookies are responsible for:

  • Store temporary information during your user’s visits
  • Store and manage the login information on your website
  • Track and personalize user activity

Cookies are extremely useful, but at the same time, they can be harmful to users. These cookies store important information and they can be used maliciously. As a result, there are many internet regulations that have been put in place this year and one of them is the EU Cookie Law.

It is a very simple law that requires a website to disclose that cookies are being used if your website is accessed in the EU. Thus, if you get visitors from the EU, you need to make sure you give a warning.

How Do I Check What Cookies My Website Is Using

Since cookies are stored in your browser, you can use your browser to check for them. The method is different depending on the browser you use. In this example, I will use the world’s most popular web browser, Google Chrome.

Keep in mind you will see cookies from every website. Thus, to ensure you only see the cookies that your website uses, you should clear the cookies of your browser first. Then simply visit your website for your browser to acquire the cookies it uses.

Click on the Settings option on your browser.

Click on the Settings option.

Type “Content Settings” into the text box at the top of the screen. Click on the Content Settings option.

Click on the Content Settings option.

The first option you should see is Cookies. Click on the Cookies option and select the See all cookies and site data option.

Click on the See all cookies and site data option.

You will now see a full list of cookies that your browser has stored. You can expand any of them to learn what they do. It is a good idea to regularly clear your browser’s cookies. However, remember they control those very convenient automatic login fields.

How to Manage Cookies in WordPress

Today, I will demonstrate how to manage cookies in WordPress. Cookies are not easy to understand if you do not have a coding background. There are three things to do with cookies. Get, set, and delete. I will demonstrate how to go through each of these. Remember, if you’re not comfortable with code, it is best not to attempt to manage cookies.

Since you will be editing files on the backend of your website, it is highly recommended to backup your website. This will ensure that if you make a mistake, you can use the backup to revert your website before the mistake was made.

Set Cookies

The setcookie() function is used to set cookies in PHP. This will be used in the functions.php file inside of your theme. Inside of the parentheses, you can use the following parameters:

  • Name of the Cookie
  • Value of the Cookie
  • Expiration Date
  • Path
  • Domain
  • Secure
  • HttpOnly

Only the first two are mandatory. Before you add code, you need to locate your theme’s functions.php file.

Let’s start by logging into the cPanel and clicking on the File Manager option.

Click on the File Manager option.

You need to locate your theme’s functions.php file. Click on the public_html directory, then click on the wp-content folder. Inside this folder, you will find all of the content related to your website. Click on the themes folder and enter the folder of the theme you are currently using.

Finally, right-click on the functions.php file and select the Edit option.

Select the "Edit" option.

A pop-up window will show up. This box will warn you to create a backup of your files before editing anything. Click on the “Edit” button.

Click on the "Edit" button.

Upon doing so, a new tab will open containing all of the code from the file.

Copy and paste the following example cookie:[ht_message mstyle=”info” title=”” show_icon=”” id=”” class=”” style=”” ]function set_cookies() {

$visit_time = date(‘F j, Y g:i a’);

if(!isset($_COOKIE[$time_stamp])) {

// set a time stamp cookie that will last 1 year
setcookie(‘time_stamp’, $current_time, time()+31556926);

}

}[/ht_message]

This is a simple example that will create a cookie that time stamps when a user visited your website. You can see it in use if you check the cookies on your browser. It should appear as “time_stamp”.

Remember to click on the “Save Changes” button to finish.

Click on the "Save Changes" button.

You can use this example to set more complicated cookies on your website. You can also remove them at any time by deleting the code.

Get Cookies

Setting cookies is very important, but having that timestamp doesn’t quite help if we cannot use the information. So now we need to “get” the information.

In this example, we can call the cookie we just made, time_stamp, and use a shortcode to call the information. In this case, you would see the last time a user visited your website.

You can call your cookies by using the $_COOKIE[] variable.

Note: Those are not parentheses.

Here is some code that you can place in your functions.php file to accomplish this:[ht_message mstyle=”info” title=”” show_icon=”” id=”” class=”” style=”” ]function get_cookies() {
// The user’s visit time
$visit_time = date(‘F j, Y g:i a’);

// Check if the cookie was previously set
if(isset($_COOKIE[‘time_stamp’])) {

// If the cookie is set, continue with this
function visitor_message() {

// Use the Cookie
$lastvisit = $_COOKIE[‘time_stamp’];

$string .= ‘Thanks for visiting ‘. $lastvisit .’. Check out whats new’;

return $string;
}

} else {

// If the cookie was not set, do this
function visitor_message() {
$string .= ‘We see that your new and want to welcome you! Check out these resources…’ ;
return $string;
}

// Set the cookie
setcookie(‘time_stamp’, $visit_time, time()+31556926);
}

// Add a shortcode
add_shortcode(‘greet’, ‘visitor_message’);

}
add_action(‘init’, ‘get_cookies’);[/ht_message]

It is a very simple example of what you can do with the cookie you set. It will check if the cookie was set and then if it was, it will display a message with the last time you visited. If it was not set, it will welcome you as a new visitor and set the cookie. You can use the shortcode [greet] to use this information on your website.

Delete Cookies

Cookies are temporary files and they are not necessary all the time. As such, you should delete them when they are no longer useful.

To do this, you need to use the unset() function.

Deleting the plugin we just made would look like this:[ht_message mstyle=”info” title=”” show_icon=”” id=”” class=”” style=”” ]unset($_COOKIE[‘time_stamp’]);[/ht_message]

The unset function will delete or unset the cookie and this can be used in many creative ways. Just make sure not to use this out of place because you could essentially set a cookie and then unset it before the use happens, which is pointless.

Use Cookies Responsibly

Cookies can be used to store important information like login credentials. If that gets into the wrong hands, accounts can be compromised. There are multiple regulations that have recently been introduced in the EU.

Thus, if you are doing business there, then you must already be aware and compliant or you will face hefty fines. It is always a good policy to set an expiration date and delete cookies that are no longer necessary.

This is not just for safety either, cookies will slow down web browsers, which is why you should clean them every few months. Always consider how you can use cookies to your website’s advantage.

What kind of cookies do you use? Do you find it hard to manage cookies in WordPress?

The post How to Manage Cookies in WordPress appeared first on GreenGeeks.

]]>
https://www.greengeeks.com/tutorials/manage-cookies-in-wordpress/feed/ 0