简体   繁体   English

Google BigQuery Google Ads 数据传输表中的重复数据

[英]Duplicated data in Google BigQuery Google Ads Data Transfer Tables

I have configured a Google Ads DataTransfer stream from Google Ads to my GoogleBigQuery project.我已将 Google Ads 中的 Google Ads DataTransfer stream 配置到我的 GoogleBigQuery 项目中。 It runs, data flows, everything is fine.它运行,数据流动,一切都很好。 But when I decided to build a query that return an amount of money spend in the context of distinct combination of utm_marks (source, medium, campaign) I've faced a trouble with 'doublicated' data.但是,当我决定构建一个查询以返回在 utm_marks(来源、媒介、活动)的不同组合的上下文中花费的金额时,我遇到了“重复”数据的问题。

So, the query firstly goes to Adstat Table and takes the stats of every creativeId (I suppose creativeId means Ad) in every campaignId.因此,查询首先转到 Adstat 表,并获取每个广告系列 ID 中每个 creativeId(我想 creativeId 表示广告)的统计信息。 Then it takes an every utm_marks from AdTrackingUrlTemplate of every creativeId from every campaign.然后,它从每个广告系列的每个 creativeId 的 AdTrackingUrlTemplate 中获取每个 utm_marks。 Finally it merges two tables in one and in the output I have a full info about stats for every utm_mark.最后,它将两个表合并为一个,在 output 中,我有关于每个 utm_mark 统计信息的完整信息。

Query looks like this:查询如下所示:

 with 
 Adstat as (
            select * 
            from `myproject.GoogleAds.AdStats_7394379271`
        ),

 Ad as (
        select 
            CampaignId, 
            CreativeId, 
            REGEXP_EXTRACT(CreativeTrackingUrlTemplate, r"[?&]utm_source=([^&]+)") as source,
            REGEXP_EXTRACT(CreativeTrackingUrlTemplate, r"[?&]utm_medium=([^&]+)") as medium,
            REGEXP_EXTRACT(CreativeTrackingUrlTemplate, r"[?&]utm_campaign=([^&]+)") as campaign
        from 
            `myproject.GoogleAds.p_Ad_7394379271`
        where 
            CreativeTrackingUrlTemplate is not null 
        and 
            CreativeTrackingUrlTemplate!="{lpurl}"
        group by 
            CampaignId, CreativeId, source, medium, campaign
       )

select
    date, CampaignId, CreativeId, impressions, 
    Clicks, Cost, Cost * 1.2/1000000 as adCost, source, medium, campaign
from 
    Adstat 
left join  
    Ad using (CampaignId, CreativeId)
where 
    date = '2021-11-26'
and 
    CampaignId = 1688777252
and 
    CreativeId = 328994634699

output: output:

date日期 CampaignId活动 ID CreativeId创意 ID impressions印象 Clicks点击次数 adCost广告费用 source资源 medium中等的 campaign活动
2021-11-26 2021-11-26 1688777252 1688777252 328994634699 328994634699 1 1 1 1 10 10 google谷歌 cpc每次点击费用 _cntr_sale_15 _cntr_sale_15
2021-11-26 2021-11-26 1688777252 1688777252 328994634699 328994634699 1 1 1 1 10 10 google谷歌 cpc每次点击费用 cntr_sale_16 cntr_sale_16
2021-11-26 2021-11-26 1688777252 1688777252 328994634699 328994634699 1 1 1 1 10 10 google谷歌 cpc每次点击费用 cntr_sale_17 cntr_sale_17

And there is a trouble.而且有一个麻烦。 If a creativeId during its lifetime has a several utm_marks in AdTrakingTemplate, all of them will go to result and all of them will receive a stats from AdStats Table (you can see at in output: same date, same CreativeAd, same stats, but different utms).如果一个 creativeId 在其生命周期中在 AdTrakingTemplate 中有几个 utm_marks,它们都会 go 得到结果,并且它们都会从 AdStats Table 中收到一个统计信息(您可以在 output 中看到:相同的日期,相同的 CreativeAd,相同的统计信息乌兹别克斯坦)。 So we have a double (triple,quadriple) impressions, clicks, amount spent etc. It's a pretty common case, because it's easier from manager to change a tracking template, than create a new Ad or Campaign in Google Ads.因此,我们有双倍(三倍、四倍)的展示次数、点击次数、花费金额等。这是一个很常见的情况,因为经理更改跟踪模板比在 Google Ads 中创建新的广告或广告系列更容易。

And, unfortunatly, I don`t know, how to figure it out, cause there no way to determ which exactly utm_marks were in createiveIdTrakingTemplate when some stat actcions (impressions, click, etc) were performed.而且,不幸的是,我不知道如何解决这个问题,因为在执行某些统计操作(展示次数、点击等)时,无法确定 createiveIdTrakingTemplate 中究竟是哪些 utm_marks。

Does anyone know, how to deal with it?有谁知道,如何处理? Thanks for help!感谢帮助!

You assume CreativeId is unique.您假设 CreativeId 是唯一的。 That is not the case.事实并非如此。 CreativeId is only unique in the group. CreativeId 仅在组中是唯一的。 See also https://developers.google.com/adwords/api/docs/guides/objects-methods#object_id_uniqueness另请参阅https://developers.google.com/adwords/api/docs/guides/objects-methods#object_id_uniqueness

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM