Openli
IntroductionGetting StartedTechnical DocumentationGet help
  • Getting started
    • Introduction
    • Dictionary
    • FAQ
      • IAB TCF v2.0
  • Privacy hub
    • How to create your privacy profile
    • How can I get an Openli Privacy Badge?
    • Vendor owners
    • Why are custom properties on vendors super valuable?
    • Setting up custom properties
  • Tasks
  • Cookie Consent Management
    • Quickstart
    • Checklist: Cookies
    • Cookie widget
      • Create a cookie policy
      • Create a cookie widget
      • Install the widget
      • Manually add any cookies
      • Customise your widget
      • How to get color codes
      • Set the widget language
      • Use custom link/button instead of Cookie Shield
      • Add company name to cookie pop-up
    • Categorise your cookies
    • Adding information to cookies
    • Adding information to your cookie providers
    • Blocking Cookies with Openli
    • Cookie expiration dates and lifespan
      • Changing expiration on Google Analytics cookies
  • Policy and agreement management
    • Generate your privacy policy
    • Changing an old cookie policy to a new on autopilot
    • Embed your policies and legal agreements
      • Embedding agreements without displaying a widget
    • Install the Privacy Badge
  • General Openli guides
    • Setting up SSO (Single Sign-On)
      • SSO with Azure AD (Microsoft)
      • SSO with Google
      • SSO with Okta
      • How to log in with SSO
    • Add a website to your Openli account
    • Using projects to handle multiple languages
    • Collect consents without storing IP addresses or user-agents
  • Technical documentation
    • Widget
      • Collect cookie consent
        • Blocking cookies
        • Blocking embedded media
        • Cookie-widget options
        • Consent state API
    • API
      • Services
        • Personal data
        • Subprocessors
    • Cookies set by Openli
  • System Specific Integration Guides
    • Cloudflare
  • Legacy integrations
    • Google Consent Mode
    • Google Tag Manager
      • Block cookies with GTM
      • Install Openli with GTM
      • Prevent triggers from firing in GTM
    • HubSpot
    • Pardot
    • Shopify
      • Install cookie widget
      • Integrate consent with checkout
    • Square Online
    • Squarespace
    • Webflow
    • Wix
Powered by GitBook
On this page
  • Setup
  • What's next?
  • General widget options
  1. Technical documentation

Widget

Openli provides you with an easy and straightforward approach to collect and manage consent. We have a few widgets that do just that!

Setup

The legal.js widget library requires a small snippet of JavaScript code to be included once in each page you use it on. This snippet is available in your account's Widgets section, and looks like this:

<script>
    !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)}}}();
</script>

Whenever possible, you should include the snippet as the first script in your page's <head> section:

<!doctype html>
<html>
    <head>
        ...
        <script>
            !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)}}}();
        </script>
        ...
    </head>
    <body>
        ...
    </body>
</html>

What's next?

When you have legal.js loaded, you can begin to use its functionality to collect consents, show your legal agreements, and update user-data.

General widget options

Identify a known user

Openli gives you the ability to identify your users more precisely using a unique value that your internal system already associates with them. Identifying a user this way allow us to be certain who the user is, and not to rely on cookies, which the user can change or delete.

To do this, You can provide thelegal.widget() method with a value for the identifier option.

Here is an example of identifying your user when initializing a widget:

legal.widget({
    type: "<<WIDGET TYPE>>",
    widgetPublicKey: "<<WIDGET PUBLIC KEY>>",
    identifier: "<<USER ID>>",
});

In the above example, <<USER ID>> is what you will substitute with your unique identifier for the user.

We recommend using database IDs because they tend to remain consistent over time. This helps to ensure that you can still recognize the same user in all of your analytics tools even though the user's other details might change.

Set the widget language

To set the display language, initialise your widget with the locale option set to the value for the language you desire. For example, to use Danish when the jurisdiction is Denmark, your widget's initialisation would look similar to this:

legal.widget({
    type: "...",
    widgetPublicKey: "...",
    locale: "da-dk",
});

English is the default language, and supported languages are listed below.

If you do not specify a language, or if the language you set is not supported by us in the visitor's jurisdiction, English will be used. The table below lists the supported combinations.

Language

Supported in jurisdiction

Option value

English (EN)

All jurisdictions

None, or en-us

Danish (DA)

Denmark (DK)

da-dk

Dutch (NL)

Netherlands (NL)

nl-nl

English (EN)

Great Britain (GB)

en-gb

English (EN)

United States (US)

en-us

French (FR)

France (FR)

fr-fr

German (DE)

Austria (AT)

de-at

German (DE)

Germany (DE)

de-de

Norwegian (NO)

Norway (NO)

no-no

Swedish (SV)

Sweden (SE)

sv-se

PreviousCollect consents without storing IP addresses or user-agentsNextCollect cookie consent

Last updated 4 months ago