安装 line-item-manager
环境配置
安装python3 具体根据系统安装 https://www.python.org/downloads/
python3安装完成后用 pip 下载 line-item-manager
pip install line-item-manager
# 已安装可升级
pip install --upgrade line-item-manager
获取 GAM 密钥文件并开启配置权限
根据链接:https://developers.google.com/ad-manager/api/start?hl=zh-cn 页面中视频操作。
-
进入 IAM和管理 中 服务账号 并点击创建服务账号,按提示填写服务账号相关信息
-
点击 创建并继续后选择角色 Project > Editor 后,点击 完成 按钮
-
搜索刚刚创建的 服务账号并点击进入
-
进入 服务账号详情,选择 密钥Tab, 点击 添加密钥 > 创建新密钥
-
弹窗选择 JSON 项,点击创建,就会自动下载 并保存 JSON密钥文件
-
打开 Ad Manage 平台,进入 Admin > Global setting 页面,确认勾选 API access 选项后,点击 Add a service account user 按钮。
-
输入刚刚创建的服务账号生成的服务账号 Email,并设置相关权限。按保存就基本完成啦
创建配置文件
创建项目将刚刚创建的密钥文件存储在根目录
通过命令生成默认的配置文件,配置文件有大量注释解释字段的含义
line_item_manager show > prebid_config.yml
⚠️ 重要,配置前请认真阅读下面文档
Getting Started with Prebid for Header Bidding
Order 与 line-Item 设置
###############################################################################
# Orders (required)
# Allowed Templating Key Words: Bidder, Media, Order, Misc
###############################################################################
order:
name: "Prebid-{{ bidder_name }}-{{ media_type }}-{{ time }} {{ cpm_min }}-{{ cpm_max }}"
# appliedTeamIds: # list (optional)
# - 12345678
# - 23456789
###############################################################################
# Line Items (required)
# Allowed Templating Key Words: Bidder, Media, CPM, Misc
#
# Supported Types: price_priority, standard, sponsorship
# datetimes use: "%m/%d/%y %H:%M" (ex. 11/17/20 21:28)
# - default timezone is UTC
# timezones: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
###############################################################################
line_item:
name: "Prebid-{{ bidder_name }}-{{ media_type }}-{{ time }} @ {{ cpm }}"
item_type: "price_priority"
# Optional
# priority: 12
# goal: # required if sponsorship item_type
# units: 5
# unitType: "VIEWABLE_IMPRESSIONS"
# goalType: "LIFETIME"
# start_datetime: "11/17/20 21:28"
# end_datetime: "12/17/20 21:28"
# timezone: "UTC"
在 prebid-line-item-manager
文件夹中创建配置文件 config.yml,具体配置文档可移步至Line-Item-Manager文档 查看调整。
publisher:
network_code: "[Google广告网络Code]"
network_name: "[Google广告网络Name]"
advertiser: # at least one of the following is required {id, name}, id is checked first
name: "Prebid by Ronny"
# id: 123517519
# type: "AD_NETWORK" # optional: defaults to "ADVERTISER"
###############################################################################
# Creatives (required)
# Allowed Templating Key Words: Bidder, Media, Misc
#
# For additional explanations on settings see the following:
# banner: https://docs.prebid.org/adops/step-by-step.html
# video: https://docs.prebid.org/adops/setting-up-prebid-video-in-dfp.html
###############################################################################
creative: # at least one of the following types is required {video, banner}
name: "Prebid-{{ media_type }}"
banner:
safe_frame: False # optional: defaults to True
# size_override: False # optional: defaults to True with a 1x1 creative
sizes: # list
- width: 1
height: 1
- width: 300
height: 250
- width: 320
height: 480
snippet: |
<script src = "https://cdn.jsdelivr.net/npm/prebid-universal-creative@latest/dist/%%PATTERN:hb_format%%.js"></script>
<script>
var ucTagData = {};
ucTagData.adServerDomain = "";
ucTagData.pubUrl = "%%PATTERN:url%%";
ucTagData.targetingMap = %%PATTERN:TARGETINGMAP%%;
try {
ucTag.renderAd(document, ucTagData);
} catch (e) {
console.log(e);
}
</script>
# max_duration: 15000 # optional: defaults to 30000, see settings.yml
# duration: 15000 # optional: defaults to value of max_duration above
###############################################################################
# Orders (required)
# Allowed Templating Key Words: Bidder, Media, Order, Misc
###############################################################################
order:
name: "Prebid-{{ media_type }}-{{ time }} {{ cpm_min }}-{{ cpm_max }}"
# appliedTeamIds: # list (optional)
# - 12345678
# - 23456789
###############################################################################
# Line Items (required)
# Allowed Templating Key Words: Bidder, Media, CPM, Misc
#
# Supported Types: price_priority, standard, sponsorship
# datetimes use: "%m/%d/%y %H:%M" (ex. 11/17/20 21:28)
# - default timezone is UTC
# timezones: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
###############################################################################
line_item:
name: "Prebid-{{ media_type }}-{{ time }} @ {{ cpm }}"
item_type: "price_priority"
# Optional
# priority: 12
# goal: # required if sponsorship item_type
# units: 5
# unitType: "VIEWABLE_IMPRESSIONS"
# goalType: "LIFETIME"
# start_datetime: "11/17/20 21:28"
# end_datetime: "12/17/20 21:28"
# timezone: "UTC"
rate:
currency: "USD" # required
granularity: #
type: "med" # required, choices: "low", "med", "high", "auto", "dense", "custom"
# https://github.com/prebid/line-item-manager/blob/fdefe3bfbbe1ebd4d43d9e94a4053c7a957d859f/line_item_manager/conf.d/settings.yml#L51
# custom: # optional, requires type "custom" above
# - min: 0.01
# max: 1.50
# interval: 0.01
# - min: 30.50
# max: 50.00
# interval: 0.50
# optional properties
# vcpm: 100000 # viewable impressions will be enabled
Creative 广告素材设置
###############################################################################
# Creatives (required)
# Allowed Templating Key Words: Bidder, Media, Misc
#
# For additional explanations on settings see the following:
# banner: https://docs.prebid.org/adops/step-by-step.html
# video: https://docs.prebid.org/adops/setting-up-prebid-video-in-dfp.html
###############################################################################
creative: # at least one of the following types is required {video, banner}
name: "Prebid {{ bidder_name }}-{{ media_type }}"
banner:
# safe_frame: False # optional: defaults to True
# size_override: False # optional: defaults to True with a 1x1 creative
sizes: # 配置广告素材大小
- height: 1
width: 1
- height: 480
width: 640
# ...
snippet: |
# 广告素材代码片段,根据广告运营策略选择对应的素材
<script src = "https://..."></script>
<script>
...
</script>
根据下面的文档配置素材 GAM Step by Step - Banner/In-Renderer/AMP/Native Creatives
- Send all bids 对应使用的素材
<script src = "https://cdn.jsdelivr.net/npm/prebid-universal-creative@latest/dist/PUCFILE"></script><script>
var ucTagData = {};
ucTagData.adServerDomain = "";
ucTagData.pubUrl = "%%PATTERN:url%%";
ucTagData.adId = "%%PATTERN:hb_adid_BIDDERCODE%%";
ucTagData.cacheHost = "%%PATTERN:hb_cache_host_BIDDERCODE%%";
ucTagData.cachePath = "%%PATTERN:hb_cache_path_BIDDERCODE%%";
ucTagData.uuid = "%%PATTERN:hb_cache_id_BIDDERCODE%%";
ucTagData.mediaType = "%%PATTERN:hb_format_BIDDERCODE%%";
ucTagData.env = "%%PATTERN:hb_env%%";
ucTagData.size = "%%PATTERN:hb_size_BIDDERCODE%%";
ucTagData.hbPb = "%%PATTERN:hb_pb_BIDDERCODE%%";
// mobileResize needed for mobile GAM only
ucTagData.mobileResize = "hb_size:%%PATTERN:hb_size_BIDDERCODE%%";
// these next two are only needed for native creatives but are ok for banner
ucTagData.requestAllAssets = true;
ucTagData.clickUrlUnesc = "%%CLICK_URL_UNESC%%";
try {
ucTag.renderAd(document, ucTagData);
} catch (e) {
console.log(e);
}
</script>
- Send Top Price Bid 对应使用的素材
<script src = "https://cdn.jsdelivr.net/npm/prebid-universal-creative@latest/dist/PUCFILE"></script><script>
var ucTagData = {};
ucTagData.adServerDomain = "";
ucTagData.pubUrl = "%%PATTERN:url%%";
ucTagData.targetingMap = %%PATTERN:TARGETINGMAP%%;
ucTagData.hbPb = "%%PATTERN:hb_pb%%";
// these next two are only needed for native creatives but are ok for banner
ucTagData.requestAllAssets = true;
ucTagData.clickUrlUnesc = "%%CLICK_URL_UNESC%%";
try {
ucTag.renderAd(document, ucTagData);
} catch (e) {
console.log(e);
}
</script>
Custom Granularity 价格自定义粒度设置
设置后将根据 rate
对应订单项,如:
假设你的价格粒度设置为:
- 价格区间:$0.10~$20.00,
- 间隔(interval) 为:0.10 那么将为你的订单生成 200 个订单项
###############################################################################
# Rate (required)
# Allowed Templating Key Words: None
#
# Granularity type definitions can be found here:
# https://docs.prebid.org/prebid-mobile/adops-price-granularity.html
#
# NOTE:
# 1. granularity in Prebid.js config must align with this granularity
# 2. all currency values are rounded to two decimal places (closest hundreth)
###############################################################################
rate:
currency: "USD" # required
granularity:
type: "med" # required, choices: "low", "med", "high", "auto", "dense", "custom"
# custom: # optional, requires type "custom" above
# - min: 0.10
# max: 30.00
# interval: 0.10
# - min: 30.50
# max: 50.00
# interval: 0.50
# optional properties
# vcpm: 100000 # viewable impressions will be enabled
执行创建程序
成功的话就会打印以上信息完成订单创建。
line-item-manager create config.yml -b [bidder]
激活订单
进入广告订单管理页面,配置文件中配置了 advertiser.name
可以方便索引到相关订单
进入详情,点击 Approve 按钮激活订单,等待生效即可。
相关阅读: Line-Item-Manager文档 GAM Step by Step - Banner/In-Renderer/AMP/Native Creatives 发送所有报价与最高价对比 — Send All Bids vs Top Price