ORTB
中 / EN
分册导航

GPP String 结构与编码

容器协议

定位与分类

全球隐私平台(Global Privacy Platform,GPP)字符串的总体布局、Header 三字段(Type / Version / Sections)、modified base64 编码规则与首字符识别约定(D=GPP 串,C=互动广告局(Interactive Advertising Bureau,IAB)Europe 透明度与同意框架(Transparency & Consent Framework,TCF)v2 的独立 TC String)。

GPP section
§3 (Header)
状态
GPP String v1.0
分隔符
~ (section) · . (subsection)
编码
modified base64 · 6 bit/char

字符串与字段布局

[Header]~[Discrete Section]~[Discrete Section]…
  • ~ section 分隔符:把 Header 与各 section 载荷依次串起来
  • . section 内子段分隔符(如 TC String 的 segments)
  • modified base64(RFC 4648 字符表,每字符 6 bit,右侧补 0 至 6 的倍数)

首字符为 D(bits 000011 → base64 索引 3)即 GPP 字符串;为 C(000010 → 2)即 IAB Europe TCF v2 TC String——与旧格式向后兼容的识别约定。

字符串结构与 Header

字段类型描述
TypeInt(6)固定为 3,标识这是 GPP Header 字段。ENFixed to 3 as "GPP Header field".
VersionInt(6)GPP 规范版本号(当前为 1)。ENVersion of the GPP spec (currently 1).
SectionsRange(Fibonacci)字符串所含 Section ID 的有序列表;ID 顺序与其 section 在串中的出现顺序一致。Fibonacci range 编码:先读 int(12) 的条目数 amount,随后每条读一个 single/group 标志位 + 一个 Fibonacci 偏移量(相对上一个 ID,首条以 0 为基准);若为 group 再读一个 Fibonacci 长度。ENOrdered list of Section IDs contained in the string; IDs appear in the same order as their sections. Fibonacci range: int(12) amount, then per item a single/group bit + Fibonacci offset (from last seen ID, 0-based for the first entry), groups add a Fibonacci length.

编码数据类型

这张表是后面所有字段表的读法基础:TC String 里出现的 Range(Fibonacci)、N-Bitfield、Datetime 等术语都在此定义,建议先扫一遍再往下看。

名称编码描述
Boolean1 bit在 GPP JS API 的输出约定中 0=true、1=false(具体含义由各 section 自己的文档定义)。EN0=true, 1=false in the GPP JS API output convention (section-specific docs define meaning).
Integer (fixed)x bits定长整数;常见位宽为 3、6、12、16、24、36 bit。ENFixed-length integer; usual lengths 3, 6, 12, 16, 24, 36 bits.
Integer (Fibonacci)variableFibonacci 编码整数;位串总以连续两个 1("11")结束。ENFibonacci-coded integer; bit sequence always ends with "11".
String (fixed)x×6 bits每个字符占 6 bit,值为 ASCII 码减 65;用于语言码与国家码。ENEach character: ASCII − 65 as Int(6); used for language/country codes.
Datetime36 bits自 1970-01-01 UTC 起的十分之一秒数(即 Math.round(Date.now()/100))。ENDeciseconds since 1970-01-01 UTC (Math.round(Date.now()/100)).
Bitfield (fixed)x bits每个 ID 占一个布尔位;首位对应 ID 1。ENOne boolean per ID; first bit ↔ ID 1.
N-BitfieldInt(16) length + bitfield变长 bitfield,前置一个 Int(16) 表示其长度。ENVariable-length bitfield prefixed by its length.
Range (Int)variable先读 int(12) 条目数,随后每条:single/group 标志位 + int(16) 起始值(group 再加 int(16) 结束值);结果不保证有序。ENint(12) count, then per item: single/group bit + int(16) start (+ int(16) end for groups); not necessarily sorted.
Range (Fibonacci)variable先读 int(12) 条目数,随后每条:single/group 标志位 + 相对上一个 ID 的 Fibonacci 偏移(group 再加 Fibonacci 长度);必须有序。ENint(12) count, then per item: single/group bit + Fibonacci offset from last seen ID (+ Fibonacci group length); must be sorted.
OptimizedRangevariable一个布尔开关:1 → Fibonacci Range;0 → 变长 bitfield。ENBoolean switch: 1 → Fibonacci Range; 0 → variable-length bitfield.
ArrayOfRanges / N-ArrayOfRangesvariable先读 int(12) 记录数;每条记录含 key + type + ID 集合(为向下兼容保留的旧结构)。ENint(12) record count; per record key + type + id collection (legacy downward-compatible shape).

承载与访问

GPP String 整串经 OpenRTB 的 regs.gpp 字段或 URL 宏 ${GPP_STRING} 承载;本次交易实际生效的 section 由 gpp_sid 声明,详见 gpp_sid 分册。

URLMacro描述
gpp${GPP_STRING_XXXXX}URL-safe 编码的 GPP 字符串;XXXXX 为接收方供应商的 GPP ID。没有 GPP ID 的供应商可接收 ${GPP_STRING}。ENURL-safe encoded GPP string; XXXXX is the receiving vendor's GPP ID. Vendors without a GPP ID may receive ${GPP_STRING}.
gpp_sid${GPP_SID}本次交易生效的 Section ID;通常为单个 ID,少数情况下为逗号分隔的两个。ENSection ID(s) in force for the transaction; normally a single ID, rarely two comma-separated.

gpp_sid gpp_sid 语义与多段应用

版本差异

GPP String v1.0(2022-09-28 发布,2023-11-03 澄清修订)+ TCF EU v2 TC String(Final v.2.2 基线,含 2.3/2.4 修订)。Section 注册表收录至官方 Section Information.md 最新(ID 1–27)。

失效形态

  • 首字符不是 D(GPP 字符串)或 C(独立 TC String),无法识别格式
  • 分隔符错用:section 之间必须用 ~,TCF subsection 之间必须用 .
  • section 载荷的 modified base64 解码失败(非法字符或长度不足)
本章正文迁移自老 /protocol/gpp-tcf 单页,素材与官方规范一致。