Search
Close this search box.

Documentation

In this article

Categories

Recent articles

Wrapping content in consent shortcodes

We have made numerous integrations with popular services and plugins to control consent automatically and add placeholders when necessary. In some cases, you might want to use shortcodes instead to wrap your content. There are a few things to consider;

  • When used in combination with caching, the ‘cache_redirect=true’ attribute should be added
  • When using multiple Consent Area shortcodes on a page, make sure to assign unique ID’s to each shortcode. For example: id=”block1″, id=”block2″
  • The shortcodes come with a placeholder text. You can use CSS to design the placeholder to your needs (examples below).
  • You will need to manually add these wrappers in HTML.
  • A page reload or redirect is necessary to trigger the content in your consent area.

If you need an integration with a service or plugin, please log a support ticket. If the plugin is actively supported and has a decent following, we will integrate if needed, or write an article on how to use the script center for this purpose.

The shortcode

Below you will find the shortcode wrapper. The first opening shortcode should be wrapped in brackets [shortcode], the closing shortcode should be wrapped in [/shortcode]. In the examples below I’ll remove the square brackets in the examples below, to prevent WordPress from rendering it as shortcode, which we don’t want here. 

In combination with caching

By default, the page is reloaded on consent, to make sure the PHP is executed. If you use caching, add the cache_redirect attribute, like this cache_redirect=true. When this is enabled, the plugin redirects the pages to a URL with ?cmplz_consent=1 behind. This allows the caching tool to cache the consent page separately.

NB. It’s recommended to try using clientside=true to improve performance. If it doesn’t work, please remove.

Specifying categories

You can also select which category should be accepted for the content, by adding the category attribute.

Overriding the text

By using the ‘text’ attribute you can change the text on the blocked content placeholder. A commonly used text is “Accept marketing cookies to view this content”.

An example with styling


Hello! Please revoke your cookie settings to see a placeholder

Used CSS for this placeholder

You can download, and customize the cookie flaticon here.

Join 700.000 users and install The Privacy Suite for WordPress locally, automated or fully customized, and access our awesome support if you need any help!

Complianz has received its Google CMP Certification to conform to requirements for publishers using Google advertising products.