Consent String - Section Encoding Scenarios & Variations
Given the range of the IDs to encode, Didomi SDK will select the most optimized encoding mechanism in order to generate the smallest cookie size. The scenarios in this page demonstrate how this works.
In this page:
enabled: refers to the list of purpose or vendor for which the end user have accepted the consent or the legitimate interest
disabled: refers to the list of purpose or vendors for which the end user have rejected the consent or the legitimate interest
unknown: the end user did not yet provide their consent for the given purpose or vendor
Example #1: Non-continuous IDs with Enabled, Disabled, and Undefined Statuses
The following example shows how encoding works with enabled and disabled IDs, including an undefined ID (5). The IDs in use here are small, and we can see that BitField encoding is more efficient than the other algorithms.
BitField Encoded
Field | Value | Encode Value | Size |
---|---|---|---|
StartFromOne | 1 | 1 | 1 bit |
StartID | |||
NumberOfIDs | 8 | 0000000000001000 | 16 bits |
IDs Statuses (id : status) | |||
1 : Enabled | 10 | 10 | |
2 : Enabled | 10 | 10 | |
3 : Disabled | 01 | 01 | |
4 : Disabled | 01 | 01 | |
5 : Undefined | 00 | 00 | |
6 : Enabled | 10 | 10 | |
7 : Enabled | 10 | 10 | |
8 : Enabled | 10 | 10 | |
BitField | 1010010100101010 | 16 bits | |
Encoding Result | 100000000000010001010010100101010 | 33 bits |
Range Encoding
Field | Value | Encode Value | Size |
---|---|---|---|
EncodedStatuses | Undefined, Enabled | 1100 | 4 bits |
NumberOfRanges | 1 | 0000000000000001 | 16 bits |
SingleIdRange | 1 | 1 | 1 bit |
RangeStart | 5 | 0000000000000101 | 16 bits |
NumberOfRanges | 2 | 0000000000000010 | 16 bits |
SingleIdRange | 0 | 0 | 1 bit |
RangeStart | 1 | 0000000000000001 | 16 bits |
RangeEnd | 2 | 0000000000000010 | 16 bits |
SingleIdRange | 0 | 0 | 1 bit |
RangeStart | 6 | 0000000000000110 | 16 bits |
RangeEnd | 8 | 0000000000001000 | 16 bits |
Encoding Result | 11000000000000000001100000000000001010000000000000010000000000000000010000000000000010000000000000001100000000000001000 | 119 bits |
Fibonacci Encoding
Field | Value | Encoded Value | Size |
---|---|---|---|
EncodedStatuses | Disabled, Enabled | 0100 | 4 bits |
NumberOfRanges | 1 | 0000000000000001 | 16 bits |
FibonacciRangeStart | 3 | 0011 | 4 bits |
FibonacciNumberIdsInRange | 2 | 011 | 3 bits |
NumberOfRanges | 2 | 0000000000000010 | 16 bits |
FibonacciRangeStart | 1 | 11 | 2 bits |
FibonacciNumberIdsInRange | 2 | 011 | 3 bits |
FibonacciRangeStart | 6 | 10011 | 5 bits |
FibonacciNumberIdsInRange | 3 | 0011 | 4 bits |
Encoding Result | 010000000000000000010011011000000000000001011011100110011 | 57 bits |
Example #2: Continuous Range of Enabled IDs
The following example shows how encoding works with a continuous range of IDs for enabled purposes or vendors. The range of IDs is not very low (128-132), and we can see that the Fibonacci encoding produces a more efficient result than other encoding algorithms.
BitField Encoded
Field | Value | Encode Value | Size |
---|---|---|---|
StartFromOne | 0 | 0 | 1 bit |
StartID | 128 | 0000000010000000 | 16 bits |
NumberOfIDs | 5 | 0000000000000101 | 16 bits |
IDs Statuses (id : status) | |||
128 : Enabled | 10 | 10 | |
129 : Enabled | 10 | 10 | |
130 : Enabled | 10 | 10 | |
131 : Enabled | 10 | 10 | |
132 : Enabled | 10 | 10 | |
BitField | 1010101010 | 10 bits | |
Encoding Result | 0000000001000000000000000000001011010101010 | 43 bits |
Range Encoding
Field | Value | Encode Value | Size |
---|---|---|---|
EncodedStatuses | Enabled | 0000 | 4 bits |
NumberOfRanges | 1 | 0000000000000001 | 16 bits |
SingleIdRange | 0 | 0 | 1 bit |
RangeStart | 128 | 0000000010000000 | 16 bits |
RangeEnd | 132 | 0000000010000100 | 16 bits |
Encoding Result | 00000000000000000001000000000100000000000000010000100 | 53 bits |
Fibonacci Encoding
Field | Value | Encoded Value | Size |
---|---|---|---|
EncodedStatuses | Enabled | 0000 | 4 bits |
NumberOfRanges | 1 | 0000000000000001 | 16 bits |
FibonacciRangeStart | 128 | 00010001011 | 11 bits |
FibonacciNumberIdsInRange | 5 | 00011 | 5 bits |
Encoding Result | 000000000000000000010001000101100011 | 36 bits |
Last updated