Skip to content

Start tracking after consent

Load Loomduct only after a visitor agrees, if your site needs consent.

Loomduct sets no cookies and writes nothing to the device. Whether you still need consent depends on where your visitors are and what you collect: in the EU, reading details like screen size or time zone from the device can fall under ePrivacy rules. Check with your legal team. If you need consent first, start Loomduct only after the visitor agrees.

Before you start

  • Loomduct installed on your site. See the Quick start.

Steps

Stop Loomduct from starting on its own

With npm, do not call load() when the app starts: creating the instance sends nothing. With the script tag, add data-manual-load.

index.html
<script
  async
  src="https://cdn.loomduct.com/@loomduct/js@latest/dist/cdn/loomduct.js"
  data-token="lmt_your_project_token"
  data-manual-load
></script>

Call load() when the visitor agrees

src/consent.ts
consentBanner.onAccept(() => {
  loomduct.load()
})

Replace consentBanner.onAccept with the callback of your consent tool. Until load() runs, nothing is sent. Calls to track() and identify() made before it are kept in memory and sent once it runs.

You can also start with the basics and add a plugin, like client hints, only after consent:

src/consent.ts
import { clientHints } from '@loomduct/js/client-hints'

consentBanner.onAccept(() => {
  loomduct.use(clientHints())
})

With the script tag, use the plugin's name: loomduct.use('client-hints'). Its code downloads only then.

Check that it worked

Open your site in a private window and do not accept. The browser's network tab shows no request to /l/e. Accept, and a request to /l/e follows.