Re: how to get the geo data of google ads one day?

2021-11-16 Thread 'chaoming chen' via AdWords API and Google Ads API Forum

thank you for your remind, I checked my code again,  there were some 
problems when inserted into the MySQL database.
 There were 15 original data returned by the API. but There were two 
questions: 
1. the same AD group returned two pieces of the same data in the same city. 
2. The click and impressions data were wrong. All clicks were 0. The 
impressions was a little data 
can you show me what's your return data  when you use the GAQL

[image: 01.png]
在2021年11月16日星期二 UTC+8 下午2:55:21 写道:

>
> Another idea 
>
> can you provide the results of customer ID: 2326004878 ran the follow SQL:
>
> SELECT ad_group.id,geographic_view.resource_name, 
> segments.geo_target_province, segments.geo_target_region, 
> segments.geo_target_county, segments.geo_target_county, 
> segments.geo_target_postal_code,segments.date, metrics.average_cost, 
> metrics.average_cpc, metrics.conversions, metrics.conversions_value, 
> metrics.conversions_value, metrics.clicks, metrics.ctr,metrics.impressions 
> FROM geographic_view WHERE segments.date = '2021-11-14'
>
> ?
> 在2021年11月16日星期二 UTC+8 下午2:30:45 写道:
>
>> Hi Chaoming,
>>
>> Thank you for providing further details to your concern.
>>
>> I am afraid that our team would not be able to investigate the issue with 
>> current details. With this, please provide instead the following details as 
>> it will greatly help in our investigation: 
>>
>>- complete request 
>>
>> 
>> and response 
>>
>> 
>>  logs 
>>with request ID 
>>
>> 
>> and request header 
>>
>> 
>>  generated 
>>on your end 
>>- Screenshot of the UI (translated in English) where you are 
>>comparing the API result 
>>
>>
>> Please provide the requested information via the *Reply privately to 
>> author* option for privacy purposes. If this option is not available, 
>> you may send the details directly to our googleadsa...@google.com alias 
>> instead.
>>
>>
>> Regards,
>>
>> Reminder: Share your feedback about the Google Ads (AdWords) API! Take 
>> the 2021 Google Ads API and AdWords API Annual Survey 
>> 
>>   
>> [image: Google Logo] 
>> Ernie John Blanca Tacata 
>> Google Ads API Team 
>>   
>>
>> ref:_00D1U1174p._5004Q2R92V3:ref
>>
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/0a32cad8-12bd-4bdc-8238-4418c633ed9bn%40googlegroups.com.


Re: how to get the geo data of google ads one day?

2021-11-15 Thread 'chaoming chen' via AdWords API and Google Ads API Forum

Another idea 

can you provide the results of customer ID: 2326004878 ran the follow SQL:

SELECT ad_group.id,geographic_view.resource_name, 
segments.geo_target_province, segments.geo_target_region, 
segments.geo_target_county, segments.geo_target_county, 
segments.geo_target_postal_code,segments.date, metrics.average_cost, 
metrics.average_cpc, metrics.conversions, metrics.conversions_value, 
metrics.conversions_value, metrics.clicks, metrics.ctr,metrics.impressions 
FROM geographic_view WHERE segments.date = '2021-11-14'

?
在2021年11月16日星期二 UTC+8 下午2:30:45 写道:

> Hi Chaoming,
>
> Thank you for providing further details to your concern.
>
> I am afraid that our team would not be able to investigate the issue with 
> current details. With this, please provide instead the following details as 
> it will greatly help in our investigation: 
>
>- complete request 
>
> 
> and response 
>
> 
>  logs 
>with request ID 
>
> 
> and request header 
>
> 
>  generated 
>on your end 
>- Screenshot of the UI (translated in English) where you are comparing 
>the API result 
>
>
> Please provide the requested information via the *Reply privately to 
> author* option for privacy purposes. If this option is not available, you 
> may send the details directly to our googleadsa...@google.com alias 
> instead.
>
>
> Regards,
>
> Reminder: Share your feedback about the Google Ads (AdWords) API! Take the 
> 2021 
> Google Ads API and AdWords API Annual Survey 
> 
>   
> [image: Google Logo] 
> Ernie John Blanca Tacata 
> Google Ads API Team 
>   
>
> ref:_00D1U1174p._5004Q2R92V3:ref
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/54b1add4-f931-4f2f-a241-522727e0b831n%40googlegroups.com.


Re: how to get the geo data of google ads one day?

2021-11-15 Thread 'chaoming chen' via AdWords API and Google Ads API Forum
I use the official website laravel demo code, and the screenshot cannot be 
taken. The core code is as follows:

public function getAgeRangeReporting(GoogleAdsClient $googleAdsClient, 
$customer_id,?string $customer_name,$report_type=0)
{
if($report_type==1){
//get gender report
$sql = "SELECT gender_view.resource_name, segments.date, 
metrics.average_cost, metrics.average_cpc, metrics.active_view_cpm, 
metrics.conversions, metrics.conversions_value, metrics.clicks, 
metrics.ctr, metrics.impressions, ad_group_criterion.gender.type FROM 
gender_view WHERE segments.date = '{$this->date}'";
}else if($report_type==2){
//get geo report
$sql = "SELECT ad_group.id,geographic_view.resource_name, 
segments.geo_target_province, segments.geo_target_region, 
segments.geo_target_city, segments.geo_target_county, 
segments.geo_target_postal_code,segments.date, metrics.average_cost, 
metrics.average_cpc, metrics.conversions, metrics.conversions_value, 
metrics.clicks, metrics.ctr, metrics.impressions FROM geographic_view WHERE 
segments.date = '{$this->date}'";
}else{
//get age report
$sql =
'SELECT age_range_view.resource_name,'
. "segments.date,"
. "metrics.average_cost,"
. "metrics.average_cpc,"
. "metrics.active_view_cpm,"
. "metrics.conversions,"
. "metrics.conversions_value,"
. "metrics.ctr,"
. "metrics.impressions,"
. "metrics.clicks,ad_group_criterion.age_range.type "
. 'FROM age_range_view '
. "WHERE segments.date = '{$this->date}'";
}
// echo $sql."\r\n";
try {
$this->adsSql($googleAdsClient, $customer_id, $sql, function ($result) use 
($customer_id, $customer_name,$report_type) {
/** @var GoogleAdsServerStreamDecorator $result */
foreach ($result->iterateAllElements() as $googleAdsRow) {

/** @var GoogleAdsRow $googleAdsRow */

$age_range_view = 
$report_type==1?$googleAdsRow->getGenderView():$googleAdsRow->getAgeRangeView();
if($report_type==2){
$age_range_view =$googleAdsRow->getGeographicView();
}

$resource_name = $age_range_view->getResourceName();
$segments = $googleAdsRow->getSegments();
$metrics = $googleAdsRow->getMetrics();

$group_info = explode('/', $resource_name);
$group_data = explode('~', $group_info[3]);
if($report_type==2){
$group_id = $googleAdsRow->getAdGroup()->getId();
}else{
$group_id = $group_data[0];
}


$money = 0;
$average_cpc = round($metrics->getAverageCpc() / 100, 2);

if ($metrics->getClicks() > 0 && $average_cpc > 0) {
$money = round($average_cpc * $metrics->getClicks(), 2);
}

$conversions = $metrics->getConversions();
$clicks = $metrics->getClicks();

$conversions_ctr = 0;

if ($clicks > 0 && $conversions > 0) {
$conversions_ctr = round(($conversions / $clicks) * 100, 2);
}

$group_info = DB::connection('mysql_ads')->table('group')->where('group_id', 
$group_id)->first(['group_name', 'customer_name']);

$metrics_data = [
'group_id' => $group_id,
'group_name' => $group_info->group_name,
'customer_id' => $customer_id,
'customer_name' => $group_info->customer_name,
'criterion_id' => $group_data[1],
'average_cost' => round($metrics->getAverageCost() / 100, 2),
'average_cpc' => round($metrics->getAverageCpc() / 100, 2),
'active_view_cpm' => 
!empty($metrics->getActiveViewCpm())?round($metrics->getActiveViewCpm() 
/ 100, 2):0,
'conversions' => $conversions,
'conversions_value' => $metrics->getConversionsValue(),
'conversions_ctr' => $conversions_ctr,
'ctr' => round($metrics->getCtr() * 100, 2),
'clicks' => $metrics->getClicks(),
'impressions' => $metrics->getImpressions(),
'cost' => $money,
'historical_creative_quality_score' => 
$metrics->getHistoricalCreativeQualityScore(),
'historical_quality_score' => $metrics->getHistoricalQualityScore(),
'historical_landing_page_quality_score' => 
$metrics->getHistoricalLandingPageQualityScore(),
'historical_search_predicted_ctr' => 
$metrics->getHistoricalSearchPredictedCtr(),
'date' => $segments->getDate(),
'report_type' =>$report_type
];
if($report_type ==1){
$group_criterion = $googleAdsRow->getAdGroupCriterion();
//Google\Ads\GoogleAds\V8\Enums\GenderTypeEnum\GenderType
$gender = $group_criterion->getGender();
if($gender){
$gender_type = $gender->getType();
$metrics_data['gender_type'] = (int)$gender_type;
}
}else if($report_type == 2){
$city = $segments->getGeoTargetCity();
if($city){
$arr = explode('/',$city);
$metrics_data['city'] = $arr[count($arr)-1];
}
$province = $segments->getGeoTargetProvince();
if($province){
$arr = explode('/',$province);
$metrics_data['province'] = $arr[count($arr)-1];
}
}else{
$group_criterion = $googleAdsRow->getAdGroupCriterion();
//Google\Ads\GoogleAds\V8\Enums\AgeRangeTypeEnum\AgeRangeType
$age = $group_criterion->getAgeRange();
if($age){
$age_type = $age->getType();
$metrics_data['age_range_type'] = (int)$age_type;
}
}
DB::connection('mysql_ads')->table('group_age_rang')->updateOrInsert(
['group_id' => $group_id, 'criterion_id' => 
$group_data[1],'date'=>$this->date],
$metrics_data
);

}
});
} catch (\Exception $e) {
$error_data = json_decode($e->getMessage(), true);
echo $customer_id . '

how to get the geo data of google ads one day?

2021-11-14 Thread 'chaoming chen' via AdWords API and Google Ads API Forum
I am a google ads manager customer's developer
 the ads customer id is: 2326004878 not manager account
I use this SQL:
SELECT ad_group.id,geographic_view.resource_name, 
segments.geo_target_province, segments.geo_target_region, 
segments.geo_target_city, segments.geo_target_county, 
segments.geo_target_postal_code,segments.date, metrics.average_cost, 
metrics.average_cpc, metrics.conversions, metrics.conversions_value, 
metrics.clicks, metrics.ctr, metrics.impressions FROM geographic_view WHERE 
segments.date = '2021-11-14'
get tree items:

[image: 01.png]
but google ads's background has 29 items
[image: 02.png]

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/b2a873e5-f8a3-4ca7-bf87-29cdec303acan%40googlegroups.com.