Show Gutenberg Block by Domain Referer

Showing content in WordPress to visitors who are coming from specific referring domains is now possible with Gutenberg + Conditional Blocks.

Referer blocks allow you to display unique content such as discount codes, upsells, or just friendly messages to visitors who are coming to your site from a specific domain referer.

This is a premium condition to change the visibility of WordPress content using Conditional Blocks Pro.
(P.S This block is a Reusable Block + Conditions. It won’t be shown if you’ve purchased Conditional Blocks Pro)

How do referer blocks work?

A referer is the website that links to your site. Conditional Blocks can detect if the visitor has come to your site from a referring site’s domain. You can then specifically target visitors by displaying selected blocks that have the initial website domain set as a referer condition.

Try it out with our site, we have a referer block setup on our homepage from wordpress.org:

  1. Go to our WordPress plugin page: https://wordpress.org/plugins/conditional-blocks/
  2. Click on any link from the plugin that goes back to conditionalblocks.com
  3. You should see a unique block on our homepage that states you’ve come from wordpress.org because wordpress.org is the referer.
Referer notice block for vistors from wordpress.org

Set up referers on a block

Add referer URL to any Gutenberg block
Add referer URL to any Gutenberg block

It’s easy to set up domain referers on a Gutenberg Block.

  1. Make sure you have Conditional Blocks Pro up and running.
  2. Select the block that you want to appear only for the specific domain referer.
  3. In the right sidebar select Conditions Pro and write the domain you want.

Note: you should write the domain without https:// and www. You can also add multiple domains by comma seperating them like so conditionalblocks.com, wordpress.org google.com.


Limitations

There are several reasons why domain refers may not show up as expected, so please look over the following reasons.

HTTP Referer not available

This feature relies on the HTTP referer being sent from the referring domain and properly being read by your website server. Conditional Blocks won’t be able to detect the referring domain if the information is not available.

Some sites don’t want to pass referer information.

Some websites will remove all referring information on their links. This happens when they purposely don’t want the referring information to be passed on. We recommend that you inspect the html of the referring site to verify if they are disabling the information.

The attribute rel="noreferrer" inside a html link will hide all referer information from the linked website. The link will look like this as HTML:

<a href="https://conditionalblocks.com" rel="noreferrer">Click Here</a>

You can ask the website owner to not use the rel="noreferrer" for any links to your site.

WordPress & No Referrer

Some WordPress sites may strip out the referer information by default. In this case it’s possible edit the link manually or use a plugin that removes the no referrer attribute from all links on the site.

URL Shortners

Sites like twitter.com use their own url shortner ( t.co ) to redirect links from tweets. You’ll need to use the the short domain in the domain referer settings.