Cookie Consent Banner Setup
Wire your own cookie consent banner to the JavaScript SDK: hold tracking until a visitor responds, then log their decision with the consent method.
Overview
Intempt doesn't ship a built-in cookie consent banner. You build the banner yourself, either custom markup or a third-party consent management platform, and wire its accept/reject actions to the JavaScript SDK. The SDK gives you two building blocks for this: optIn()/optOut() to control whether tracking calls fire at all, and consent() to log the visitor's decision against a consent category.
Once a decision is logged with consent(), it shows up on that customer's Privacy tab, and it can gate which categories a journey is allowed to message from the Journey builder.
📘 Good to know
This guide covers wiring the SDK to a banner you already have. To define the consent categories you'll pass to consent() (for example analytics or marketing), see Managing consents.
Before you begin
You need:
- The JavaScript SDK installed on your site. See Basic Intempt installation.
- At least one consent category already configured for your project, matching the
categoryvalue your banner will send. See Managing consents for how categories are defined.
Setting up the banner
Step 1: Decide whether to hold tracking until the visitor responds
Tracking is on by default: isUserOptIn() returns true until you call optOut(). If your banner needs to work opt-in-first, call optOut() as soon as the install snippet loads, before the visitor has answered the banner:
<script>
intempt.optOut();
</script>📘 Good to know
While a visitor is opted out, tracking calls (track, record, product, page and session events) are not sent. consent() is still sent in every state, so the accept or reject decision is always recorded, even if the visitor has not been opted back in.
Step 2: Build the banner
Add your own banner markup, or embed a third-party consent management platform. It needs at least an accept action and a reject action, each wired to a click handler.
Step 3: Record the visitor's decision
Call consent() from each handler, matching category to the category you defined in Settings:
function onAccept() {
intempt.optIn();
intempt.consent({
action: 'accept',
validUntil: Date.now() + (365 * 24 * 60 * 60 * 1000),
category: 'analytics'
});
}
function onReject() {
intempt.consent({
action: 'reject',
validUntil: Date.now() + (365 * 24 * 60 * 60 * 1000),
category: 'analytics'
});
intempt.optOut();
}onAccept calls optIn() so tracking starts. consent() does not need it, because it is sent whether or not the visitor is opted in. onReject records the rejection with consent() and then calls optOut() so tracking stays off.
For the full consent() parameter table and the optIn/optOut/isUserOptIn reference, see the JavaScript SDK reference.
Where to go next
- Managing consents to define the categories you pass to
consent(). - Consent Management Overview to see where logged consent shows up and how it gates journeys.
- JavaScript SDK reference for the full method list.
- Basic Intempt installation for the install snippet.
Identifying Users Across Sessions
Call identify() as soon as you know a visitor's real identity so their prior anonymous activity, and every session after, ties to the same profile.
JavaScript SDK
Full API reference for IntemptJS — event tracking, user identification, consent, and product tracking in the browser.
