How to Target GDPR Location in the WordPress

Targeting GDPR location (General Data Protection Regulation location), otherwise, locating visitors who are under the GDPR law is essential for today’s business.

In our previous article “SAFE GUIDE for the GDPR and Location Data Collection” we explained what GDPR is and how it can be safely applied on a website and how you can insure yourself against possible problems and violations of someone’s GDPR.

What is the meaning of the term: GDPR LOCATION?

The term “GDPR location” means all technical applications and functionalities, textual and media content, as well as public and hidden services that collect or contain all sensitive information, which apply exclusively to users and visitors from the European Union.

To clarify the definition, anyone who visits your WordPress website, or any other website and comes from the European Union, is a citizen of the same, and its location falls under GDPR laws and regulations.

How can we detect the GDPR location?

For the detection of GDPR location, that is, detecting GDPR location is feasible using GPS locations or IP addresses.

It is much more advisable to use an IP address for this type of detection because every computer communicates via an IP address and precision in this case is not much important. Also, not every device has GPS, and many users turn off or disable the GPS location and therefore is not very reliable in our case.

How to Target GDPR Location in the WordPress?

WordPress is a modular CMS for which there are many plugins but one has a special purpose to locate users who fall under the GDPR site.

CF Geo Plugin is a WordPress plugin that has GDPR location detection tools and provides the ability to manipulate content and pages via shortcode, PHP or JavaScript.

Detect GDPR Location in WordPress using shortcode

The shortcode in the WordPress is a simple set of functions for creating WordPress shortcodes for use in posts and pages. CF Geo Plugin has its own clearly defined shortcodes that have their own purpose and functionality. To detect the GDPR location we use a shortcode called [in_eu]

How can we use it?

[in_eu]You are from the European Union (accept HTML)[/in_eu]

With this CF Geo Plugin shortcode you can show or hide content for the visitor of European Union (EU).

Parameters

default – (accept: text) – This will be returned if EU shortcode not match (optional)

exclude – (accept: comma separated text) – this parameter gives to shortcode new functionality. If you wrap some content with a shortcode and add this parameter with continent, country, region, city name or code, it will hide that content from that setup location.

include – (accept: comma separated text) – this parameter gives to shortcode new functionality. If you wrap some content with a shortcode and add this parameter with continent, country, region, city name or code, it will show that content from that setup location.

cache – (no values) – This is single property with no values. It was used for the cache support that forced AJAX requests to get proper geo information. This shortcode can be also automatically added if cache setting is enabled.

Return

These shortcodes display or hide EU messages on your website.

Examples

Display EU message:

[in_eu default="You are NOT from the European Union"]You are from the European Union[/in_eu]

Returns: You are NOT from the European Union

Detect GDPR Location in WordPress using JavaScript

JavaScript is one of the most important scripts when it comes to WordPress and you have several objects through which you can access to geo information.

Within the first line of the HTML element, we have placed special objects through which you can access to geo information:

  • window.wp.geo – Using standard WordPress JavaScript wp object
  • window.cfgeo – Using direct window object
  • cf.geoplugin – Using old CF Geo Plugin cf object (included conflict fix from the version 6.x.x).

How can we use it to locate GDPR in JavaScript?

if(window.wp.geo.in_eu)
{
	/* GDPR location - Do anything you want for the GDPR visitors */
}
else
{
	/* ...else nothing, or... ...something */
}

No explanation is needed for this. It’s too easy. Just add an adequate check window.wp.geo.in_eu in your JavaScript and do what you want.

window.wp.geo.in_eu returns integer 1 for EU visitors or 0 for non EU visitors (GDPR location visitors).

For more information on JavaScript objects in CF Geo Plugin, you can find in the documentation: JavaScript Integration

Detect GDPR Location in WordPress using PHP

Similar to JavaScript, the CF Geo Plugin has a PHP approach that can be used in themes and other plugins to do GDPR location check.

<?php
## Check is CF Geo Plugin active and running
if(class_exists('CF_Geoplugin'))
{
    ## Initialize CF Geo Plugin
	$cfgeo_init = new CF_Geoplugin();
	
    ## Get CF Geo Plugin avilable objects
    $geo = $cfgeo_init->get();
	
	## Check GDPR  location
	if($geo->in_eu)
	{
		/* GDPR location - Do anything you want for the GDPR visitors */
	}
	else
	{
		/* ...else nothing, or... ...something */
	}
}

Detect GDPR Location in WordPress and do SEO Redirection to Another Location

If you need to redirect your visitors from one location to another, CF Geo Plugin has that option as well. Redirecting to or from GDPR location is possible if you select regions  and redirect to a dedicated page or another site. More about that you can read at Enable SEO Redirection and SEO Redirection Usage.

Conclusion

As you can see, with CF Geo Plugin it is easy to do a GDPR location and locate visitors from across the European Union. All you have to do is install this powerful plugin and the magic can begin.

Click to Download  latest CF Geo Plugin version 7.12.14

NOTE

Do not forget that CF Geo Plugin uses very sensitive information and you must indicate it in your privacy policy because of European GDPR law, but in fact,  CF Geo Plugin is fully valid for use and does not violate any legal acts by itself.

Ivijan-Stefan Stipić

About the author

Login

Lost your password? Register

Register

Your personal data will be used to support your experience throughout this website, to manage access to your account, and for other purposes described in our privacy policy.

Lost your password? Login