Developers

Website widget

One script tag shows your notice as a banner on your website and records each visitor's choices in the workspace's ledger.
Developer pages and contents

The tag

HTML
<script src="https://cdn.dpdpgrid.in/w/AbCdEf123456.js" data-lang="en" async></script>

Copy the exact tag from the workspace's Website tab. Put it in every page, before </body> or in <head>.

data-lang picks the notice's language, by code (see languages). Where that language is not published, the English notice is shown, or the first one published.

Allowed websites

List each website on the Website tab as an origin: https://, the host name, and a port if there is one. No path, no trailing slash. Up to 20.

Text
https://www.abcclinic.example
https://abcclinic.example

https://www.abcclinic.example and https://abcclinic.example are different origins: list both if both are used. Only https addresses are accepted.

On a website that is not listed, the browser blocks the widget's calls, and no banner appears.

If your site sends a Content-Security-Policy, allow the widget's host in script-src and connect-src:

Text
script-src https://cdn.dpdpgrid.in; connect-src https://cdn.dpdpgrid.in

What visitors see

  • A banner at the bottom with Accept all, Reject all and Choose, and a link to the full notice.
  • Choose opens a panel with each purpose, the data it uses and how long it is kept, to tick one by one.
  • The banner stays until the visitor answers the current notice. A new notice version asks again.
  • The panel keeps keyboard focus inside it, and Escape closes it. Urdu, Kashmiri and Sindhi notices read right to left.

The visitor record

The widget keeps a random visitor id in the browser's local storage under lsync-consent:{slug}, and the visitor's last choices under lsync-consent:{slug}:state. It sets no cookies and sends none.

Each answer is added to the ledger against that visitor id, with the website's origin, a hashed IP address and the browser's user agent.

If the browser lost its saved choices but kept its id, the widget asks DPDPGrid for that visitor's standing and fills the choices in.

One address can save 30 answers to a workspace in any one minute.

JavaScript

The widget sets window.LSyncConsent:

open()
Opens the choices panel (once the notice has loaded).
standing()
The visitor's choices in this browser: { [purposeCode]: true | false }.
on(event, fn)
Calls fn(standing) on "ready" (the notice has loaded) or "change" (an answer was saved). Returns a function that stops the calls.
slug
The workspace's slug.

"ready" fires only when a published notice has purposes. The script loads async, so wait for it before using it:

HTML
<button type="button" id="privacy-choices">Privacy choices</button>
<script>
  window.addEventListener("load", function () {
    var consent = window.LSyncConsent;
    if (!consent) return;
    function apply(standing) {
      if (standing.marketing) {
        // Turn on what the visitor agreed to.
      }
    }
    apply(consent.standing());
    consent.on("change", apply);
    document.getElementById("privacy-choices").addEventListener("click", function () {
      consent.open();
    });
  });
</script>
Choices kept in the browser are a convenience. For a decision your server makes, read the standing from the consent API.
Website widget · DPDPGrid developers