Skip to content
LandexHub

How to set up LandexHub Consent on WordPress

· 6 min read

On this page
  1. What the plugin does
  2. Installation and first setup
  3. Categories and banner texts
  4. Consent Mode v2 and Google Tag Manager
  5. Blocking other scripts
  6. Services list and changing consent
  7. How to check that everything works
  8. Common mistakes

LandexHub Consent is a cookie banner for WordPress that we build ourselves. This guide covers installing it from WordPress.org, setting up categories and texts, Google Consent Mode v2 and connecting it to Google Tag Manager. At the end, it shows how to check that nothing starts without consent.

What the plugin does

The plugin does not need any cloud service. It keeps its settings and consent records in your WordPress and does not send data anywhere on its own.

Feature What it does
Banner and settings window Accept all, Reject and Customize buttons, choice by category, preview in the admin
Google Consent Mode v2 Prints the default denied state in <head> before the Google tags it loads
Loading GTM or gtag.js After you enter an ID, loads the container or the tag right after the default consent state
Script blocking Runs scripts marked with a category only after consent
Site check Goes through your homepage HTML and lists scripts, iframes and pixels that load before consent
Services list A table of services and cookies for your cookie policy page
Consent log Proof of consent without IP addresses, with CSV and JSON export

The admin is available in English, Czech, Slovak, Polish and German. The plugin requires WordPress 6.3 and PHP 7.4 or newer.

Installation and first setup

  1. Remove the old banner

    If your website has another cookie banner, deactivate it. Two banners at once interfere with each other and may send conflicting signals.

  2. Install the plugin

    In the WordPress admin, open Plugins, choose to add a new plugin, search for LandexHub Consent, install it and activate it.

  3. Go through the setup wizard

    On first launch, a three-step Setup wizard opens: appearance, measurement and site check. In the measurement step, you decide whether the plugin should load Google Tag Manager, a direct measurement ID, or nothing if you add Google another way.

  4. Continue in the tabs

    You will find the other settings in the LandexHub Consent menu, in four tabs: Appearance, Services, Diagnostics and Advanced.

Categories and banner texts

The plugin works with four categories. Each maps to Google Consent Mode v2 signals:

Category Value in code Consent Mode signals
Necessary necessary security_storage, functionality_storage (always granted)
Analytics analytics analytics_storage
Marketing marketing ad_storage, ad_user_data, ad_personalization
Personalization preferences personalization_storage

The Necessary category is always on and the visitor cannot reject it. The others are off by default until the visitor switches them on.

You edit the texts on the Appearance tab under Texts & languages: the banner text, the settings window text and the category names. On a multilingual website, each language has its own version of the texts. Under Legal links, fill in the Cookie policy URL and Privacy policy URL so that the banner links to them.

How long the plugin remembers the choice is set on the Advanced tab. Consent validity is 12 months by default, Rejection validity 6 months.

The plugin prints the default Consent Mode state denied at the start of <head>, before the GTM container or gtag.js that it loads itself. You can choose between two modes:

  • Consent Mode v2 Advanced (default): the Google tag loads even before consent, stores no cookies and sends only cookieless signals that Google uses to model conversions.
  • Consent Mode v2 Basic: a direct gtag.js measurement ID does not load until the visitor agrees.

The GTM container always loads, in both modes. What each tag inside the container does before consent is set in GTM itself. The difference between the modes is explained in Google Consent Mode v2, explained simply.

  1. Enter the container ID

    Measurement IDs are added and changed on the Services page. Fill in the GTM container ID (GTM-XXXX), or a direct measurement ID for GA4 or Google Ads without a container (G-XXXX, AW-XXXX). Remove any GTM snippet you have elsewhere, for example in the theme or another plugin, so the container does not load twice.

  2. Check the tags in the container

    Google tags (GA4, Google Ads) follow the Consent Mode signals on their own. Custom HTML tags and tags from other vendors, such as Meta Pixel or LinkedIn, do not know Consent Mode. In GTM, require the matching signal in their consent settings, such as ad_storage.

  3. Use the plugin's event as a trigger

    After every decision, the plugin pushes the landexhub_consent_update event to the dataLayer, with a landexhub_consent object holding the state of each category. In GTM you can use it as a custom event trigger for tags that should fire right after consent is given.

Blocking other scripts

Scripts outside GTM, such as a pixel in the theme, become consent-dependent once you change the tag. Change the type to text/plain, add the category and, for an external script, move the address from src to data-src:

header.phpHTML
<!-- Before: the script runs right away -->
<script src="https://www.example.com/js/tracking.js"></script>

<!-- After: it runs only after consent to marketing cookies -->
<script type="text/plain" data-consent-category="marketing" data-src="https://www.example.com/js/tracking.js"></script>

A script that WordPress loads through wp_enqueue_script can be made consent-dependent in PHP with the plugin’s helper:

functions.phpPHP
<?php
add_action( 'wp_enqueue_scripts', function () {
    wp_enqueue_script( 'example-pixel', get_stylesheet_directory_uri() . '/js/pixel.js', array(), '1.0', true );

    if ( class_exists( 'LandexHub_Consent' ) ) {
        LandexHub_Consent::block_handle( 'example-pixel', 'marketing' );
    }
} );

Make theme changes in a child theme so that theme updates do not overwrite them. For each source it finds, the Services page shows where it comes from and how to make it consent-dependent. The full guide is in the plugin documentation.

On your cookie policy page, add the [landexhub_consent_services] shortcode or the “Services & cookies overview” block. It prints a table of the services found on your homepage and the services from your list, with their category, known cookies and links to the providers’ privacy policies.

By default, the plugin adds a Cookie settings link to the website footer. Instead, you can turn on the Cookie icon after consent, or place the link anywhere with the [landexhub_consent_settings] shortcode or the “Cookie settings link” block. A change of consent reaches Consent Mode immediately.

How to check that everything works

  1. Run the diagnostics

    On the Diagnostics tab, go through the check results. The plugin warns you, for example, about a tag placed before the default consent state or a container loaded twice.

  2. Go through the site check findings

    On the Services page, check that every source is either consent-dependent or follows Consent Mode. The check sees only the homepage HTML, not subpages or tags inside GTM.

  3. Test in the browser

    In a private window, reject cookies and check in the developer tools that no analytics or advertising cookies are stored. Then change your consent through the footer link and check that the tools start.

  4. Look at the log

    Your test choices should appear in the Consent log.

A manual check, step by step, is described in How to check that your cookie banner waits for consent.

Common mistakes

  • GTM container loaded twice. Once by the plugin, once by the theme or another plugin.
  • Tracking code above wp_head(). A snippet in the theme loads before the default consent state and measures without consent. Move it below wp_head(), or let the plugin load the container.
  • Blocked Google tags. Tags that follow Consent Mode do not get type="text/plain".
  • Custom HTML in GTM without consent settings. Another vendor’s pixel inside the container fires regardless of the banner.
  • A source only on a subpage. The site check does not find it on the homepage. Also go through pages with a video, map or form.

Frequently asked questions

Do I need the Pro version of LandexHub Consent?
No. The banner, Consent Mode v2, script blocking, the site check and the consent log are all in the free plugin from WordPress.org. The plugin does not require any add-on.
Does the plugin store visitors' IP addresses?
Not in the consent log. It stores a random consent ID, the chosen categories, the time, the page path and a fingerprint of the banner texts. The records stay in your WordPress database.
Is the plugin suitable for websites with Google AdSense?
For personalised ads through AdSense or Ad Manager to visitors from the EEA, Google requires a banner certified for IAB TCF. LandexHub Consent does not support TCF, so it is not a good fit for such a website.

Similar guides

5 min read

Google Consent Mode v2, explained simply

What Google Consent Mode v2 is, which four consent signals it sends, how to set it up in code and in Tag Manager, and how to check that it works.