Documentation

Install the Sadang Tracker SDK

One script tag in the head of every page. Your dashboard gives you the exact URLs for your site and region.

1. Add the script

Add this as high as possible in the <head> of every page, above Google Tag Manager or any Google tag. Use the URLs shown for your site in the uForge dashboard; they depend on your region. If you use Google tags, also add Google's default consent snippet above it - see Sadang and Google Tag Manager.

<script
  src="https://cdn.uk.uforge.build/sadang/sadang-tracker.min.js"
  async
  data-config-url="https://cdn.uk.uforge.build/sadang/config/YOUR-SITE-ID.rules.json"
  data-allowed-origins="https://sdg.uk.uforge.build"></script>

2. What each attribute does

AttributeWhat it does
srcThe Sadang script for your region (UK or Thailand)
asyncLoads the script without blocking the page
data-config-urlYour site's settings: consent banner, default consent level, which features are on. Without it, Sadang looks for a configuration named after your domain, then falls back to a safe default that denies everything.
data-allowed-originsHosts, besides your own site, that Sadang may send measurement data to
data-config-hash (optional)A checksum of your configuration file, so a changed file is rejected

3. Add a way to change consent

Visitors must be able to change their mind. Add a link in your footer that reopens the banner:

<a href="https://www.example.com/cookie-policy" data-cookie-preferences>Cookie preferences</a>
<script>
  document.addEventListener('click', function (e) {
    var link = e.target.closest('[data-cookie-preferences]');
    if (link && window.SadangTracker) { e.preventDefault(); SadangTracker.showConsentBanner(); }
  });
</script>

The href points at your cookie policy, so the link still works if the script has not loaded. Put the script in a file if your site uses a strict Content Security Policy.

4. Single-page apps

Sadang follows browser history changes automatically. If your app changes page another way, dispatch a sadang:navigation event on window after each route change.

5. Check it is working

  1. Open your site in a Chrome or Edge private window. The banner should appear. (Firefox private windows send Global Privacy Control, which Sadang treats as a refusal, so no banner appears there.)
  2. In the browser console, type dataLayer: you should see a consent default entry with the advertising and analytics types denied.
  3. Click Reject all. You should see an update entry, and a sadang_consent_tier cookie.
  4. Reload. The banner should not appear again.

Our guide how to check what your site runs before consent covers the full check.

Using Google Tag Manager?

Keep the Sadang script above your Tag Manager snippet. See Sadang and Google Tag Manager.