Google Ads Preview BigQuery Data Transer - google-bigquery

There are no matching costs between Google Ads Preview Data Transfer's tables - ads_GeoStats and ads_CampaignStats.
I'm interested in getting matched locations cost report for our world campaigns and I used ads_GeoStats table for that but when I check the value of metrics_cost_micros in ads_GeoStats, it shows that it is less than the value of metrics_cost_micros in ads_CampaignStats or Google Ads console.
Steps to reproduce:
select sum(metrics_cost_micros/1000000) from a.google_ads_preview.ads_CampaignStats_*
where campaign_id = 123
and _DATA_DATE ='YYYY-MM-DD'
select sum(metrics_cost_micros/1000000) from a.google_ads_preview.ads_GeoStats_*
where campaign_id =123
and _DATA_DATE = 'YYYY-MM-DD'
Any help in understanding why this gap exists?
Thanks,
Roy
Expect the same costs from the google ads console and ads_GeoStats table.

Related

Grafana charts grouped by month with Google BigQuery Datasource?

I use Grafana (the version is 8.3.3) with the Google BigQuery datasource.
I can't display a graph with a monthly distribution (with the macro $__timeGroup)
My query :
SELECT * FROM ( SELECT
$__timeGroup(usage_start_time, 1M),
project.id AS metric,
SUM(cost) AS value FROM
`project.view_v3` WHERE
$__timeFilter(usage_start_time) GROUP BY 1, 2 ORDER BY 1 ASC ) WHERE value > 0
With a visualization by table, it seems to work, but not in graphical mode :
enter image description here
thanks for helping,
Regards,
Didier

Firebase Analytics vs. BigQuery - Average engagement time per screen

My engagement time shown in Firebase analytics, under Engagement -> Pages and Screens -> Page Title and Screen Name differs from that which is returned by the following BigQuery query.
SELECT
(SELECT value.string_value FROM UNNEST(event_params) WHERE key="firebase_screen") AS screen,
AVG((SELECT value.int_value FROM UNNEST(event_params) WHERE key="engagement_time_msec")) AS avg_engagement_time,
FROM
`ABC.events_20210923`
GROUP BY screen
ORDER BY avg_engagement_time DESC
However the numbers shown in Firebase Analytics are completely different from the numbers returned by the query. The descending order in which they are shown is about 65% right. Is this a completely different metric or is my query just wrong?

BigQuery imports from GoogleAds show all CPM related Fields with value 0

Hello wonderful person!
I've followed this guide to import google ads campaign info to a BigQuery database.
My goal is to create a simple query that can be stored as a view and accessed from Data Studio to make a report. But some fields like AverageCpm are always set to 0.
I also have a data studio report made using google ads as source for reference and I can access all the campaigns from the google ads platform.
Here is the query I'm working on:
SELECT
c.ExternalCustomerId,
c.CampaignName as name,
c.CampaignStatus,
cs.date as dia,
SUM(cs.Impressions) AS Impressions,
SUM(cs.Interactions) AS Interactions,
AVG(cs.AverageCpm) AS CPM,
SUM(cs.Cost) AS Cost
FROM
`<DB>.google_ads.Campaign_<ACCOUNT_ID>` c
LEFT JOIN
`<DB>.google_ads.CampaignStats_<ACCOUNT_ID>` cs
ON
(c.CampaignId = cs.CampaignId
AND cs._DATA_DATE BETWEEN
DATE_ADD(CURRENT_DATE(), INTERVAL -80 DAY) AND DATE_ADD(CURRENT_DATE(), INTERVAL -1 DAY))
WHERE
c._DATA_DATE = c._LATEST_DATE
and c.CampaignName = 'THE_NAME_OF_MY_CAMPAIGN'
GROUP BY
1, 2, 3 , 4
ORDER BY
CampaignName, dia
The field Impressions, returns with a value that is consistent with my reference datastudio report and the info I see in google ads stats, so I feel I'm in the right track.
My problem is that some fields like CampaignStats.AverageCpm , CampaignStats.Cost are always 0.
For example, the query:
Select * from `<DB>.google_ads.p_CampaignStats_<ACCOUNT_ID>` where AverageCpm >0;
Returns with no results.
I'm thinking permission problems? But I have administrator access to all the company's accounts.
Database is backfilled correctly.
I've tried generating a new dataset: Same problem and I don't see if there is a way to configure how google makes the imports.
What else could it be? What else can I do?
Thank you very very much!
Answer by Roman Petrochenkov, check his youtube channel he is the best.
AVG(cs.AverageCpm) AS CPM, Is not correct
Since average of averages is not average of the total.
You need to calculate CPM manually as SUM(Impressions)/SUM(NULLIF(Cost, 0)) as CPM
Although, I would recommend against calculating it in the BQ and would recommend to calculate int in the BI (data studio in this case).

How to get firebase console event details such as first_open, app_remove and Registration_Success using big query for last two weeks?

I'm creating visualization for App download count, the app removes count and user registration counts from firebase console data for the last two weeks. It gives us the total count of the selected period but we need date wise count for each. For that, we plan to get the data count using a big query. how do we get all metrics by writing a single query?
We will get all the metrics using single query has below
SELECT event_date,count(*),platform,event_name FROM `apple-XYZ.analytics_XXXXXX.events_*` where
(event_name = "app_remove" or event_name = "first_open" or event_name = "Registration_Success") and
(event_date between "20200419" and "20200502") and (stream_id = "XYZ" or stream_id = "ZYX") and
(platform = "ANDROID" or platform = "IOS") group by platform, event_date, event_name order by event_date;
Result: for two weeks (From 19-04-2020 to 02-04-2020)

How to select google analytics segment in google big query? SQL

I create Google Analytics data source in Tableau.
The data source has the segment by "new user".
Now, I would like to push the Google Analytics in Google Bigquery and create the same data source in Tableau by creating a data source from Google Bigquery.
After checking the GA data source in Google Bigquery project.
There is no segment in Bigquery.
How to query by segment "new user" in Google Bigquery??
You can look at BigQuery GA Schema to see all fields that are exported there.
The field totals.newVisits has what you are looking for:
select
hits.transaction.transactionid tid,
date,
totals.pageviews pageviews,
hits.item.itemquantity item_qtd,
hits.transaction.transactionrevenue / 1e6 rvn,
totals.bounces bounces,
fullvisitorid fv,
visitid v,
totals.timeonsite tos,
totals.newVisits new_visit
FROM
`project_id.dataset_id.ga_sessions*`,
unnest(hits) hits
WHERE
1 = 1
AND PARSE_TIMESTAMP('%Y%m%d', REGEXP_EXTRACT(_table_suffix, r'.*_(.*)')) BETWEEN TIMESTAMP('2017-05-10')
AND TIMESTAMP('2017-05-10')
group by
tid, date, pageviews, item_qtd, rvn, bounces, fv, v, tos, new_visit
Notice that this field is defined in the session level.