Consent management
Community home
  • Overview
  • Responsability of actors
  • Releases notes
  • Setup Guides
    • Tag Manager
      • TagCommander
      • Google Tag Manager (GTM)
      • Consent Mode in TAG
      • Consent Mode in GTM
      • Adobe Launch
    • Websites (Hardcoded)
    • Mobile apps
      • iOS
        • ATT - App Tracking Transparency (iOS 14.5+)
      • Android
  • User Guides
    • Categories & Tags
      • Manage Categories
      • Manage Vendors
      • Assign Categories
    • Privacy Banners
      • Banner Templates
        • Accessibility Template
      • Manage Banner
      • Deploy Banner
      • Copy Banner
    • Dashboard
    • Exports
    • Options
  • Extensions
    • Cookie Scanner
    • TagFirewall
    • Tag Hierarchy
  • Marketing Preferences Center
    • Marketing Preferences Center (additional module)
  • Knowledge Base
    • Consent Object
    • Consent cookies exemption
      • Implementation guide for exempted consent statistics FR market
    • Consent Cookie
    • IAB TCF V2.0 Consent
    • IAB TCF V2.0 and Google FAQ
    • IAB TCF V2.2 Release details
      • IAB TCF v2.2 CMP requirements
      • IAB TCF v2.2 Migration guide Web
      • IAB TCF v2.2 Migration guide App
    • CCPA & Global Privacy control
  • Rest data API
    • GET/PUT Consents / preferences
  • Onsite API
    • Getting Started
    • consent.get
    • consent.update
    • consent.revoke
    • consent.onUpdate
    • consent.onReady
    • consentBanner.show
    • consentBanner.hide
    • consentCenter.show
    • consentCenter.hide
  • PLATFORM API
    • Get statistics
Powered by GitBook
On this page
  • Examples
  • Update categories and vendors
  • Update IAB TCF/ACM categories and vendors
  • Accept all categories and vendors
  • Refuse all categories and vendors
  • Specify update action
  1. Onsite API

consent.update

Method to update TrustCommander consent OnSite via JavaScript.

The Commanders Act OnSite API stub has to be installed before using any of the OnSite API functions.

cact('consent.update', consentObject)

The consent.update method allows to update the consent with JavaScript. It has to be called with a Consent Object that includes the updated settings. TrustCommander will deep merge the status fields of the current Consent Object with the provided object and automatically update all meta properties and the consent.status property automatically. In case a consent.status field is provided with value all-on, all-off or unset all other updates are ignored and all categories and vendor settings will be set to on, off or unset accordingly.

All unconfigured categories and vendors are ignored when deep-merging the consent objects.

Examples

Update categories and vendors

cact('consent.update', {
    categories: {
        '2': { status: 'on' }
    },
    vendors: {
        '1': { status: 'on' }
    }
});

Below you can see how the Consent Object is affected by this update.

/* Consent Object Before Update
{
    meta: { ... },
    consent: {
        status: "mixed",
        categories: {
            "1": { status: "on" },
            "2": { status: "off" }
        },
        vendors: {
            "1": { status: "off" },
            "2": { status: "on"}
        }     
    }
}
*/

// Update
cact('consent.update', {
    categories: {
        '2': { status: 'on' }
    },
    vendors: {
        '1': { status: 'on' }
    }
});

/* Consent Object After Update
{
    meta: { ... }, // automatically updated
    consent: {
        status: "all-on", // automatically updated
        categories: {
            "1": { status: "on" },
            "2": { status: "on" } // updated
        },
        vendors: {
            "1": { status: "on" }, // updated
            "2": { status: "on"}
        }     
    }
}
*/

Update IAB TCF/ACM categories and vendors

cact('consent.update', {
    categories: {
        '1': { // non-IAB category
            status: 'on' 
        },
        'tcf2_1': { // TCF purpose 1
            status: 'on' // no legintStatus for purpose 1
        },
        'tcf2_2': { // TCF purpose 2
            status: 'off',
            legIntStatus: 'on'
        },
        'tcf2_sf_1': { // TCF special feature 1
            status: 'on'
        }
    },
    vendors: {
        'tcf2_1': { // TCF vendor 1
            status: 'on',
            legIntStatus: 'off'
        },
        'tcf2_2': { // TCF vendor 2
            status: 'on',
            legIntStatus: 'on'
        },
        'acm_1': { // ACM vendor 1
            status: 'on'
        }
    }
});

Accept all categories and vendors

cact('consent.update', { 
    status: 'all-on'
});

Specifying a category or vendor will not have any effect.

cact('consent.update', { 
    status: 'all-on', 
    categories: {
        '2': { status: 'unset' } // ignored as global status is specified
    }
});

Below you can see how the Consent Object is affected by this update.

/* Consent Object Before Update
{
    meta: { ... },
    consent: {
        status: "unset",
        categories: {
            "1": { status: "unset" },
            "2": { status: "unset" }
        },
        vendors: {
            "1": { status: "unset" },
            "2": { status: "unset"}
        }     
    }
}
*/

// Update Method
cact('consent.update', { 
    status: 'all-on'
});

/* Consent Object After Update
{
    meta: { ... }, // automatically updated
    consent: {
        status: "all-on",
        categories: {
            "1": { status: "on" }, // automatically updated
            "2": { status: "on" } // automatically updated
        },
        vendors: {
            "1": { status: "on" }, // automatically updated
            "2": { status: "on"} // automatically updated
        }     
    }
}
*/

Refuse all categories and vendors

cact('consent.update', { 
    status: 'all-off'
});

Specifying a category or vendor will not have any effect.

cact('consent.update', { 
    status: 'all-off', 
    categories: {
        '2': { status: 'on' } // ignored as global status is specified
    }
});

Below you can see how the Consent Object is affected by this update. Note: required categories are not affected.

/* Consent Object Before Update
{
    meta: { ... },
    consent: {
        status: "mixed",
        categories: {
            "1": { status: "on" },
            "2": { status: "off" },
            "3": { status: "on", required: true }
        },
        vendors: {
            "1": { status: "on" },
            "2": { status: "on"}
        }     
    }
}
*/

// Update Method
cact('consent.update', { 
    status: 'all-off'
});

/* Consent Object After Update
{
    meta: { ... }, // automatically updated
    consent: {
        status: "all-off",
        categories: {
            "1": { status: "off" }, // automatically updated
            "2": { status: "off" }, // automatically updated
            "3": { status: "on", required: true } // unchanged
        },
        vendors: {
            "1": { status: "off" }, // automatically updated
            "2": { status: "off"} // automatically updated
        }     
    }
}
*/

Specify update action

You can specify an action inside the update parameters:

cact('consent.update', {
    action: 'banner_button',
    categories: {
        '2': { status: 'on' }
    },
    vendors: {
        '1': { status: 'on' }
    }
});

This action value will be used to compute your dashboard metrics. If it is omitted, the default value is banner_button.

The allowed values are:

  • banner_button

  • pc_save

  • page_click

  • scroll

  • browse

Additionally, the following values are allowed for optout only (status: 'all-off' ):

  • banner_cross

Previousconsent.getNextconsent.revoke

Last updated 2 years ago