Creating an API Endpoint (optional)

By default, Consent stores your user’s consent information in the Transcend backend entirely in the user’s browser. This is sufficient to respect user’s consent choices as they navigate your site.

However, if you would like to store and restore the user’s consent information in your own backend, e.g. to ensure that logged-in users’ consent information is persisted across sessions and browsers, you will need to create a custom endpoint to store and return that information.

To persist user tracking consent & the Do-Not-Sell preference to your backend, use this snippet which privately synchronizes tracking consent from all of your first-party domains, and then sends the latest consent data to /your-backend-sync-endpoint as an HTTP POST request.

// wait for cross-domain sync
await airgap.sync();
// POST consent data to your backend
navigator.sendBeacon(
'/your-backend-sync-endpoint',
JSON.stringify({
consent: airgap.getConsent(),
// user: getUser(),
// auth: getBackendSignedAuthTokenForUser(),
})
)

To restore server-stored consent to a known logged-in user, dynamically include an onload handler on your Consent Manager script uniquely for the user once, as such:

<script
onload="airgap.setConsent(event, {Functional:true, Advertising:true, Analytics:true, SaleOfInfo: true})"
src="https://cdn.transcend.io/cm/{your-bundle-id}/airgap.js"
></script>

Default consent emitted from Transcend's backend can be managed in the advanced settings section of the admin dashboard.