Embed your cookie policy

Legal Monster helps you to manage and update your cookie policy. This feature lets you embed your cookie policy on any page of your website.

Find your cookie policy's public-key

In your Legal Monster dashboard, click "Agreements", and copy the public-key of your cookie policy, as shown in the image below:

Add the embed code to your website

The feature requires both a containing element and a JavaScript snippet to work. You can use an existing HTML element on your page as the container, or add a new one where you want to show the cookie policy on your page.

For example, if you add the following HTML to your page where you want the cookie policy to show:

<div id="cookie-policy-container"></div>

...and add the following JavaScript, replacing GqVQYebPN2Marba6Nr1wE7J9 with the public-key of your own cookie policy:

<script>
// NOTE: This must be placed AFTER the code snippet for your cookie widget.
legal.document("#cookie-policy-container", "GqVQYebPN2Marba6Nr1wE7J9");
</script>

...then the latest version of your cookie policy will be displayed inside the <div> element.

If you want to show the cookie policy in an element that already exists on your page, you can use a standard CSS selector that matches it, instead of #cookie-policy-container in the example above.

Insertion mode (advanced)

You can use theinsertMode option to change how and where the cookie policy is placed in relation to the target element:

<script>
// NOTE: This must be placed AFTER the code snippet for your cookie widget.
legal.document(
"#cookie-policy-container",
"GqVQYebPN2Marba6Nr1wE7J9",
{
insertMode: "after",
},
);
</script>

You can change the insertion method to one of the following options:

Insertion mode

Description

replace (Default)

Replaces the specified target element with the widget

after

Inserts the widget after the specified target element

before

Inserts the widget before the specified target element

Check that your cookie policy is shown correctly

Simply visit the page on your website that you added the embed code to, and check that your cookie policy is shown as you expect!