Google ads migration missing HistoricalMetrics for some keyword

89 views
Skip to first unread message

anuj sen

unread,
Jul 6, 2022, 8:28:49 AM7/6/22
to Google Ads API and AdWords API Forum
Hi Team , 

We are migrating from google adwords to goole ads api . 
I am following below example reference
here we have  alter the method 
createKeywordPlanAdGroupKeywords 
and passing a list of text to create a list of KeywordPlanAdGroupKeyword

public static void createKeywordPlanAdGroupKeywords(
GoogleAdsClient googleAdsClient, Long customerId, String planAdGroupResource, List<String> keyWords) {
// Creates the keywords for keyword plan.

Stream<KeywordPlanAdGroupKeyword> listKeywordPlanAdGroupKeyword = keyWords.stream().map(kw-> getSafeKeyWord(kw)).distinct().map(s -> getKeywordPlanAdGroupKeyword(planAdGroupResource,s));



// Creates an operation for each plan keyword.
List<KeywordPlanAdGroupKeywordOperation> operations =
listKeywordPlanAdGroupKeyword
.map(kw -> KeywordPlanAdGroupKeywordOperation.newBuilder().setCreate(kw).build())
.collect(Collectors.toList());

try (KeywordPlanAdGroupKeywordServiceClient client =
googleAdsClient.getLatestVersion().createKeywordPlanAdGroupKeywordServiceClient()) {
// Adds the keywords.
MutateKeywordPlanAdGroupKeywordsResponse response =
client.mutateKeywordPlanAdGroupKeywords(String.valueOf(customerId), operations);
// Displays the results.
System.out.printf("#### Created MutateKeywordPlanAdGroupKeywordResult for keyword plan: %s%n", response.getResultsList().size());
for (MutateKeywordPlanAdGroupKeywordResult result : response.getResultsList()) {
// System.out.printf("Created keyword for keyword plan: %s%n", result.getResourceName());
}
}
}


public static Stream<SearhVolume> getMsVolumesList(KeywordPlanKeywordHistoricalMetrics kphm){
Stream<MonthlySearchVolume> msVolume = kphm.getKeywordMetrics().getMonthlySearchVolumesList().stream();
Stream<SearhVolume> searchvolumeStream= msVolume.map(y -> new SearhVolume(kphm.getSearchQuery(), (int)y.getYear(), y.getMonth().getNumber()-1,y.getMonthlySearches()) );
return searchvolumeStream;
}

public static List<SearhVolume> generateHistoricalMetricsForPlanId(GoogleAdsClient googleAdsClient, Long customerId, Long planId) {
String planResourceName = ResourceNames.keywordPlan(customerId, planId);

try (KeywordPlanServiceClient client =
googleAdsClient.getLatestVersion().createKeywordPlanServiceClient()) {
GenerateHistoricalMetricsResponse response = client.generateHistoricalMetrics(planResourceName);
List<KeywordPlanKeywordHistoricalMetrics> kwPlanKeywordHistoricalMetrics = response.getMetricsList();
System.out.printf("####### Recived MutateKeywordPlanAdGroupKeywordResult for keyword plan: %s%n", kwPlanKeywordHistoricalMetrics.size());

Stream<SearhVolume> searchvolumeStream = kwPlanKeywordHistoricalMetrics.stream().flatMap(x -> getMsVolumesList(x));
return searchvolumeStream.collect(Collectors.toList());

}
}


Issue : 
Here i am not able to get responce for all the keywords 
for example if i am passing 10 keywords then i am getting responce for only 8 keywods
what could be the reason for that ?? 
also how can i debug this as API is not failing any where 

Google Ads API Forum Advisor

unread,
Jul 6, 2022, 9:46:26 AM7/6/22
to anuj...@electrolux.com, adwor...@googlegroups.com
Hello,

Thanks for reaching out. Can you please provide us with the complete request and response logs so that we can further investigate?

Thanks,

Google Logo
Matt
Google Ads API Team
 


ref:_00D1U1174p._5004Q2cT7R6:ref

anuj sen

unread,
Jul 7, 2022, 6:04:48 AM7/7/22
to Google Ads API and AdWords API Forum
Hi Matt,

thanks for responding .

please find the logs 

Jul 07, 2022 12:02:53 PM com.google.ads.googleads.lib.logging.RequestLogger logAtLevel
INFO: SUCCESS REQUEST SUMMARY. Method: google.ads.googleads.v11.services.KeywordPlanCampaignService/MutateKeywordPlanCampaigns, Endpoint: googleads.googleapis.com:443, CustomerID: 5368088839, RequestID: QQznWrOtOowiayUipnb9tg, ResponseCode: OK, Fault: null.
Created campaign for keyword plan: customers/5368088839/keywordPlanCampaigns/436329584
Jul 07, 2022 12:02:53 PM com.google.ads.googleads.lib.logging.RequestLogger logAtLevel
INFO: SUCCESS REQUEST SUMMARY. Method: google.ads.googleads.v11.services.KeywordPlanAdGroupService/MutateKeywordPlanAdGroups, Endpoint: googleads.googleapis.com:443, CustomerID: 5368088839, RequestID: FAsCy2QBip20BgoejExEhQ, ResponseCode: OK, Fault: null.
Created ad group for keyword plan: customers/5368088839/keywordPlanAdGroups/445097377
Jul 07, 2022 12:02:54 PM com.google.ads.googleads.lib.logging.RequestLogger logAtLevel
INFO: SUCCESS REQUEST SUMMARY. Method: google.ads.googleads.v11.services.KeywordPlanAdGroupKeywordService/MutateKeywordPlanAdGroupKeywords, Endpoint: googleads.googleapis.com:443, CustomerID: 5368088839, RequestID: XRnWVX0M0xo7e0zbtrqOkg, ResponseCode: OK, Fault: null.
#### Created MutateKeywordPlanAdGroupKeywordResult  for keyword plan: 9
Jul 07, 2022 12:02:54 PM com.google.ads.googleads.lib.logging.RequestLogger logAtLevel
INFO: SUCCESS REQUEST SUMMARY. Method: google.ads.googleads.v11.services.KeywordPlanService/GenerateHistoricalMetrics, Endpoint: googleads.googleapis.com:443, CustomerID: null, RequestID: eJDSZpVYKT4Bfrc3rtKZ0A, ResponseCode: OK, Fault: null.
####### Recived  MutateKeywordPlanAdGroupKeywordResult  for keyword plan: 6


Let me know if you need any more information 

Regards
//Anuj 

Google Ads API Forum Advisor

unread,
Jul 7, 2022, 9:20:14 AM7/7/22
to anuj...@electrolux.com, adwor...@googlegroups.com

Hi Anuj,

I’m afraid that the provided stack trace is not enough to investigate the issue further. Could you please provide us privately with the complete logs in the format of the request and response logs as seen in their respective links.

For you to enable complete logs on your end for the client library, logging can be enabled by navigating to the Client libraries > Your client library (ex .NET) > Logging documentation, which you can access from this link.

Regards,

Google Logo
Yasar Ramjan
Google Ads API Team
 

 

ref:_00D1U1174p._5004Q2cT7R6:ref

anuj sen

unread,
Jul 7, 2022, 9:47:00 AM7/7/22
to Google Ads API and AdWords API Forum
Hi Team , 

I followed the same link given 


I have done the following steps : 
 1. added maven dependeny 

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.25</version>
</dependency>


2. added logger.properties
# Root logger option

handlers=java.util.logging.ConsoleHandler
.level=DEBUG
java.util.logging.ConsoleHandler.level=DEBUG
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
com.google.ads.googleads.lib.request.summary = WARN
com.google.ads.googleads.lib.request.detail = INFO

and then i am running my java application 
Do i need to to enable or set any other parameter to get desired logs .?? 
//Anuj 



Google Ads API Forum Advisor

unread,
Jul 7, 2022, 11:06:57 AM7/7/22
to anuj...@electrolux.com, adwor...@googlegroups.com
Hi Anuj,

Thank you for the reply.

Moving forward, Since you followed the provided logging guide but still you are unable to generate complete logs on your end, then I would suggest you to reach out to the java client library owner instead by filing an issue in the Issue tab of github via this link.

You may then send the requested information via the Reply privately to author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead.

Best regards,
Google Logo
Heidi
Google Ads API Team
 


ref:_00D1U1174p._5004Q2cT7R6:ref
Message has been deleted

Google Ads API Forum Advisor

unread,
Jul 8, 2022, 8:28:09 AM7/8/22
to anuj...@electrolux.com, adwor...@googlegroups.com

Hi Anuj,

Good day to you. I hope you’re doing well.

However, I had to delete your initial post as it contained your logs. That said, I am reposting below your concern without the attached logs :

“hi Team I am able to get the logs and it seems missing keywords are due to close_varients is it any way i can disable this feature as for UAT we need to have exact record count .”

Regarding your concern about "I am able to get the logs and it seems missing keywords are due to close_varients is it any way i can disable this feature" I’m afraid that we can not disable this feature and it seems you're experiencing de-duped please note that we de-dupe your keywords list, eliminating close variants before returning the keywords as text. For example, if your request originally contained the keywords "car" and "cars", the returned search query will only contain "cars". The list of de-duped queries will be included in close_variants field. For more information about close_variants[] you can visit it here.


Best,

Google Logo
Anthony Cyril
Google Ads API Team
 


ref:_00D1U1174p._5004Q2cT7R6:ref
Reply all
Reply to author
Forward
0 new messages