This guide is designed to help customers installing our cookie consent widget on their WordPress based website. Follow these few simple steps to get up and running quickly.

Before you start:

Before following these steps, please be sure that you have:

Check step 1 - 4 in the Get Started with Legal Monster guide to create all of the above.

How to install cookie consent in Wordpress?

Step 1: Code snippet

To install your widget, you'll need your cookie widget code snippet.

The code snippet is the text in the text area at the bottom right.

To find your code snippet, go to the Legal Monster dashboard and select "Widgets" in the side menu. Click on the cookie widget you previously created and copy the code.

It will look like this:

!function(){var i,e,t,s=window.legal=window.legal||[];if(s.SNIPPET_VERSION="3.0.0",i="https://widgets.legalmonster.com/v1/legal.js",!s.__VERSION__)if(s.invoked)window.console&&console.info&&console.info("legal.js: The initialisation snippet is included more than once on this page, and does not need to be.");else{for(s.invoked=!0,s.methods=["cookieConsent","document","ensureConsent","handleWidget","signup","user"],s.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);return e.unshift(t),s.push(e),s}},e=0;e<s.methods.length;e++)t=s.methods[e],s[t]=s.factory(t);s.load=function(e,t){var n,o=document.createElement("script");o.setAttribute("data-legalmonster","sven"),o.type="text/javascript",o.async=!0,o.src=i,(n=document.getElementsByTagName("script")[0]).parentNode.insertBefore(o,n),s.__project=e,s.__loadOptions=t||{}},s.widget=function(e){s.__project||s.load(e.widgetPublicKey),s.handleWidget(e)}}}();
type: "cookie",
widgetPublicKey: "xxxxxxxxxxxxxxxxx",

Notice that the value for widgetPublicKey will be different in your code snippet

Step 2: 'Scripts n Styles' Wordpress Plugin


To insert the code snippet on your page, you need to use a plugin called "Scripts n Styles", which you can install through Wordspress' Plugin library.

Once installed, you can access the plugin through the Wordpress Dashboard under the "Tools"-menu:

Insert widget code snippet

Once you're in the "Script n Styles" interface, make sure that you have selected "Global" from the tab menu bar at the top:

Now scroll down to the textarea called "HTML (end of the body tag)", and insert your widget code snippet here.

Make sure you hit "Save changes" at the bottom of the page for the widget to be installed properly.

Step 3: Blocking cookies

The final step you need to take to make sure your cookies are compliant is to block the scripts that set them on your website, so the widget can enable them only when a visitor gives consent.

This step is a bit more technical, however, this guide shows you how to block cookies on your site or you can follow our Google Tag Manager guide.

In the future, we plan to remove the need for Step 3, when we introduce a fully automatic blocking feature.


Congratulations on completing your first step towards collecting compliant cookie consent in Wordpress. Pad your self on the back and know that our monster Sven is proud of you.