我正在处理PHP应用程序,该应用程序每天从Adform API检索数据并将其保存到数据库。 使用维度查询的数据存在问题,例如日期和横幅与总数不匹配,无需维度检索。
例如,我向https://api.adform.com/v1/reportingstats/agency/reportdata
发帖{
"metrics": ["ctr"],
"dimensions": ["date", "banner"],
"filter": {
"date":{
"from":"2016-08-01",
"to":"2016-08-30"
},
"campaign":{
"id":campaign_id
}
},
"paging":{
"page":1,
"pageSize":10000
}
}
回应是:
{
"reportData": {
"columnHeaders": [
"date",
"banner",
"ctr"
],
"columns": [
{
"key": "date"
},
{
"key": "banner"
},
{
"key": "ctr"
}
],
"rows": [
[
"2016-08-02T00:00:00",
"banner_1",
0.00816326530612245
],
[
"2016-08-03T00:00:00",
"banner_1",
0.0024213075060532689
],
[
"2016-08-03T00:00:00",
"banner_2",
0.001207653432082372
],
[
"2016-08-04T00:00:00",
"banner_1",
0.003472222222222222
],
[
"2016-08-04T00:00:00",
"banner_2",
0.000802886393241096
],
[
"2016-08-05T00:00:00",
"banner_1",
0
],
[
"2016-08-05T00:00:00",
"banner_2",
0.000676782107058102
],
[
"2016-08-06T00:00:00",
"banner_1",
0
],
[
"2016-08-06T00:00:00",
"banner_2",
0.000926995987708068
],
[
"2016-08-07T00:00:00",
"banner_1",
0.00904977375565611
],
[
"2016-08-07T00:00:00",
"banner_2",
0.0010050565441998231
],
[
"2016-08-08T00:00:00",
"banner_1",
0.0022935779816513758
],
[
"2016-08-08T00:00:00",
"banner_2",
0.000736000744868224
],
[
"2016-08-09T00:00:00",
"banner_1",
0.0052219321148825066
],
[
"2016-08-09T00:00:00",
"banner_2",
0.000636109173796044
],
[
"2016-08-10T00:00:00",
"banner_1",
0.0057971014492753624
],
[
"2016-08-10T00:00:00",
"banner_2",
0.000724849063441972
],
[
"2016-08-11T00:00:00",
"banner_1",
0
],
[
"2016-08-11T00:00:00",
"banner_2",
0.000581557986484298
],
[
"2016-08-12T00:00:00",
"banner_1",
0.0043103448275862068
],
[
"2016-08-12T00:00:00",
"banner_2",
0.000671168239505369
],
[
"2016-08-13T00:00:00",
"banner_1",
0
],
[
"2016-08-13T00:00:00",
"banner_2",
0.000803754549989838
],
[
"2016-08-14T00:00:00",
"banner_1",
0
],
[
"2016-08-14T00:00:00",
"banner_2",
0.000989294421086104
],
[
"2016-08-15T00:00:00",
"banner_1",
0.0064516129032258056
],
[
"2016-08-15T00:00:00",
"banner_2",
0.000638244734480941
],
[
"2016-08-16T00:00:00",
"banner_2",
0.000549180805298763
],
[
"2016-08-17T00:00:00",
"banner_2",
0.000551568224222697
],
[
"2016-08-18T00:00:00",
"banner_1",
0
],
[
"2016-08-18T00:00:00",
"banner_2",
0.000678091480705215
],
[
"2016-08-19T00:00:00",
"banner_2",
0
],
[
"2016-08-22T00:00:00",
"banner_2",
0.000360310246085577
],
[
"2016-08-23T00:00:00",
"banner_2",
0.000498299661680756
],
[
"2016-08-24T00:00:00",
"banner_2",
0.000561990345005873
],
[
"2016-08-25T00:00:00",
"banner_2",
0.000364882901395197
],
[
"2016-08-26T00:00:00",
"banner_2",
0.000372206184069575
],
[
"2016-08-27T00:00:00",
"banner_2",
0.000696784292763943
],
[
"2016-08-28T00:00:00",
"banner_2",
0.00084914217341799
],
[
"2016-08-29T00:00:00",
"banner_2",
0.000441720501352769
],
[
"2016-08-30T00:00:00",
"banner_2",
0.000556096204643403
]
]
}
}
所以,总平均 CTR = 0.0015624820601283 = 0.15%
当我查询时没有任何尺寸:
{
"metrics": ["ctr"],
"filter": {
"date":{
"from":"2016-08-01",
"to":"2016-08-30"
},
"campaign":{
"id":campaign_id
}
},
"paging":{
"page":1,
"pageSize":10000
}
}
我明白了:
{
"reportData": {
"columnHeaders": [
"ctr"
],
"columns": [
{
"key": "ctr"
}
],
"rows": [
[
0.000729710843077063
]
]
}
}
CTR = 0.000729710843077063 = 0.07%
有什么问题? 为何如此差异:0.15%vs 0.07%? 可能我应该通过简单的AVG计算CTR而不是另一种方式?
我还发现了与其他API相同的问题,例如Google AnalyticsAPI和Facebook Marketing API。 使用按维度采样的数据在本地统计的总计和平均值并不总是与API本身提供的总数相同。