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.
1
cact('consent.update', consentObject)
Copied!
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

1
cact('consent.update', {
2
categories: {
3
'2': { status: 'on' }
4
},
5
vendors: {
6
'1': { status: 'on' }
7
}
8
});
Copied!
Below you can see how the Consent Object is affected by this update.
1
/* Consent Object Before Update
2
{
3
meta: { ... },
4
consent: {
5
status: "mixed",
6
categories: {
7
"1": { status: "on" },
8
"2": { status: "off" }
9
},
10
vendors: {
11
"1": { status: "off" },
12
"2": { status: "on"}
13
}
14
}
15
}
16
*/
17
18
// Update
19
cact('consent.update', {
20
categories: {
21
'2': { status: 'on' }
22
},
23
vendors: {
24
'1': { status: 'on' }
25
}
26
});
27
28
/* Consent Object After Update
29
{
30
meta: { ... }, // automatically updated
31
consent: {
32
status: "all-on", // automatically updated
33
categories: {
34
"1": { status: "on" },
35
"2": { status: "on" } // updated
36
},
37
vendors: {
38
"1": { status: "on" }, // updated
39
"2": { status: "on"}
40
}
41
}
42
}
43
*/
Copied!

Update IAB TCF/ACM categories and vendors

1
cact('consent.update', {
2
categories: {
3
'1': { // non-IAB category
4
status: 'on'
5
},
6
'tcf2_1': { // TCF purpose 1
7
status: 'on' // no legintStatus for purpose 1
8
},
9
'tcf2_2': { // TCF purpose 2
10
status: 'off',
11
legIntStatus: 'on'
12
},
13
'tcf2_sf_1': { // TCF special feature 1
14
status: 'on'
15
}
16
},
17
vendors: {
18
'tcf2_1': { // TCF vendor 1
19
status: 'on',
20
legIntStatus: 'off'
21
},
22
'tcf2_2': { // TCF vendor 2
23
status: 'on',
24
legIntStatus: 'on'
25
},
26
'acm_1': { // ACM vendor 1
27
status: 'on'
28
}
29
}
30
});
Copied!

Accept all categories and vendors

1
cact('consent.update', {
2
status: 'all-on'
3
});
Copied!
Specifying a category or vendor will not have any effect.
1
cact('consent.update', {
2
status: 'all-on',
3
categories: {
4
'2': { status: 'unset' } // ignored as global status is specified
5
}
6
});
Copied!
Below you can see how the Consent Object is affected by this update.
1
/* Consent Object Before Update
2
{
3
meta: { ... },
4
consent: {
5
status: "unset",
6
categories: {
7
"1": { status: "unset" },
8
"2": { status: "unset" }
9
},
10
vendors: {
11
"1": { status: "unset" },
12
"2": { status: "unset"}
13
}
14
}
15
}
16
*/
17
18
// Update Method
19
cact('consent.update', {
20
status: 'all-on'
21
});
22
23
/* Consent Object After Update
24
{
25
meta: { ... }, // automatically updated
26
consent: {
27
status: "all-on",
28
categories: {
29
"1": { status: "on" }, // automatically updated
30
"2": { status: "on" } // automatically updated
31
},
32
vendors: {
33
"1": { status: "on" }, // automatically updated
34
"2": { status: "on"} // automatically updated
35
}
36
}
37
}
38
*/
Copied!

Refuse all categories and vendors

1
cact('consent.update', {
2
status: 'all-off'
3
});
Copied!
Specifying a category or vendor will not have any effect.
1
cact('consent.update', {
2
status: 'all-off',
3
categories: {
4
'2': { status: 'on' } // ignored as global status is specified
5
}
6
});
Copied!
Below you can see how the Consent Object is affected by this update. Note: required categories are not affected.
1
/* Consent Object Before Update
2
{
3
meta: { ... },
4
consent: {
5
status: "mixed",
6
categories: {
7
"1": { status: "on" },
8
"2": { status: "off" },
9
"3": { status: "on", required: true }
10
},
11
vendors: {
12
"1": { status: "on" },
13
"2": { status: "on"}
14
}
15
}
16
}
17
*/
18
19
// Update Method
20
cact('consent.update', {
21
status: 'all-off'
22
});
23
24
/* Consent Object After Update
25
{
26
meta: { ... }, // automatically updated
27
consent: {
28
status: "all-off",
29
categories: {
30
"1": { status: "off" }, // automatically updated
31
"2": { status: "off" }, // automatically updated
32
"3": { status: "on", required: true } // unchanged
33
},
34
vendors: {
35
"1": { status: "off" }, // automatically updated
36
"2": { status: "off"} // automatically updated
37
}
38
}
39
}
40
*/
Copied!

Specify update action

You can specify an action inside the update parameters:
1
cact('consent.update', {
2
action: 'banner_button',
3
categories: {
4
'2': { status: 'on' }
5
},
6
vendors: {
7
'1': { status: 'on' }
8
}
9
});
Copied!
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
Last modified 4mo ago