Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Consent & Privacy

The SDK gives you two kinds of privacy control: reporting the visitor's consent from your consent management platform (CMP), and acting on the visitor's own requests to opt out or have their data deleted. This page covers both, with recipes for common consent platforms.

Privacy Controls at a Glance

The SDK offers four privacy controls, and Pushly's Privacy API offers a fifth. They do different things, so pick the one that matches the visitor's request.

The visitor wants to…
Use
Can it be undone?
What happens to their data

Answer your consent banner

Yes, report granted

Kept; nothing new is collected while consent is pending or denied

Stop receiving notifications for a while

Yes, with resume_notifications

Kept; tracking continues

Withdraw consent to notifications and tracking

Yes, with opt_in

Kept; nothing new is collected

Have their data deleted, from your site

No

Erased

Have their data deleted, as a known user

No

Erased

If your site uses a consent management platform (CMP), report the visitor's consent with the consent option on every page, and report each change with the consent command. The SDK then waits, withdraws or loads before it starts anything.

Put consent in the load call of your snippet, so it reaches the SDK before the SDK starts:

<script src="https://cdn.p-n.io/sdk/web/latest/pushly-sdk.min.js?domain_key=SDK_KEY" async></script>
<script>
  var PushlySDK = window.PushlySDK || [];
  function pushly() { PushlySDK.push(arguments) }
  pushly('load', {
    domainKey: 'DOMAIN_KEY',
    consent: 'pending' // the visitor has not answered your banner yet
  });
</script>

When your CMP answers, or the visitor changes their choice, report it:

Value
What the SDK does

pending

Waits. Nothing is started or sent, and an existing subscription is left alone. Your other commands are held until consent is reported.

granted

Loads normally. If the visitor was opted out because consent was denied earlier, that is undone, and a browser that still allows notifications is subscribed again automatically.

denied

Before starting anything, removes the visitor's push subscription and tells Pushly they opted out, exactly as opt_out does. A visitor with nothing to withdraw sends nothing at all. Events and an external ID stored on the device by an earlier visit are cleared.

not set

No consent handling: the SDK behaves as it always has.

Use 'pending' until your CMP has answered. Don't report 'denied' for a visitor who simply hasn't answered yet: that withdraws their subscription.

Each recipe keeps the snippet's load at consent: 'pending' and reports the answer with the consent command once your CMP has one. If your CMP never answers — for example because an ad blocker stops it loading — the SDK stays waiting, which keeps the visitor's data untouched.

IAB TCF (__tcfapi)

Most CMPs that support the IAB Transparency & Consent Framework v2, including OneTrust, Didomi and Sourcepoint, expose __tcfapi. Listen for its events and report consent once the visitor's choice is known:

If your CMP lists Pushly as a vendor, also check the vendor's consent, tcData.vendor.consents[VENDOR_ID], before reporting 'granted'. Where GDPR doesn't apply to the visitor, tcData.gdprApplies is false; decide whether your policy treats that as consent.

OneTrust

OneTrust calls OptanonWrapper when its script loads and again whenever the visitor saves their choices. Report consent only once the visitor has answered the banner:

Global Privacy Control

A browser that sends the Global Privacy Control signal sets navigator.globalPrivacyControl to true. If your site treats that as an opt-out, report 'denied' in the snippet itself, and keep it denied whatever your CMP reports:

A page opened with pushly_udr in its address (for example https://example.com/?pushly_udr) requests deletion for that browser, exactly as request_user_deletion does. It works whatever consent the page reports.

To turn the link off, set disableUserDeletionUrlTrigger when loading the SDK. request_user_deletion keeps working from code either way.

For how to call opt_out, opt_in and request_user_deletion directly, see SDK Methods.

Last updated