ShoppingProductAdInfo is empty

36 views
Skip to first unread message

Ahmed Adly

unread,
Aug 18, 2020, 4:33:44 PM8/18/20
to AdWords API and Google Ads API Forum
Hello,
I have this query: 

String query = "SELECT ad_group.id, "
+ "ad_group_ad.ad.id, "
+ "ad_group_ad.ad.name," +
" ad_group_ad.ad.type, " +
"ad_group_ad.ad.shopping_product_ad " +
" FROM ad_group_ad " +
"Where ad_group_ad.ad.type = \"SHOPPING_PRODUCT_AD\" ";

it runs successfully and i can extract all fields, However, when i try to extract ShoppingProductAdInfo object it returns empty although all ads has the type SHOPPING_PRODUCT_AD 

this is how i extract it

AdGroupAd adGroupAd =googleAdsRow.getAdGroupAd();
Ad ad = adGroupAd.getAd();
ShoppingProductAdInfo shoppingProductAd = ad.getShoppingProductAd();

Any ideas?

Ahmed Adly

unread,
Aug 19, 2020, 12:21:24 PM8/19/20
to AdWords API and Google Ads API Forum
Hello,
Any reply to this? We need to fix this urgently.

Google Ads API Forum Advisor Prod

unread,
Aug 19, 2020, 2:50:38 PM8/19/20
to ahme...@gmail.com, adwor...@googlegroups.com
Hello Ahmed,

Instead of using an AdGroupAd object, you should iterate through the rows in your report, much like how it is shown here.

Regards,
Anthony
Google Ads API Team 

ref:_00D1U1174p._5004Q23LHe7:ref

Ahmed Adly

unread,
Aug 19, 2020, 2:59:47 PM8/19/20
to Google Ads API Forum Advisor Prod, adwor...@googlegroups.com
Hello Anthony,
I'm already looping through them, Here is the full code: 




String query = "SELECT ad_group.id, "
+ "ad_group_ad.ad.id, "
+ "ad_group_ad.ad.name," +
" ad_group_ad.ad.type, " +
"ad_group_ad.ad.shopping_product_ad " +
" FROM ad_group_ad " +
"Where ad_group_ad.ad.type = \"SHOPPING_PRODUCT_AD\" ";

GoogleAdsServiceClient.SearchPagedResponse response = this.ExecuteGoogleAdsQuery(query, customerId);

JsonArray entryList = new JsonArray();
JsonObject entry = null;
for (GoogleAdsRow googleAdsRow : response.iterateAll()) {
entry = new JsonObject();
    AdGroupAd adGroupAd =googleAdsRow.getAdGroupAd();
Ad ad = adGroupAd.getAd();
ShoppingProductAdInfo shoppingProductAd = ad.getShoppingProductAd();
    ExpandedTextAdInfo expandedTextAdInfo = ad.getExpandedTextAd();
Campaign campaign = googleAdsRow.getCampaign();
AdGroup adGroup = googleAdsRow.getAdGroup();
Metrics metrics = googleAdsRow.getMetrics();

entry.addProperty("id", ad.getId().getValue());
entry.addProperty("name",ad.getName().getValue());
entry.addProperty("type",ad.getType().toString());

entry.addProperty("campaign",adGroup.getCampaign().getValue());
entry.addProperty("shopping_product_ad",shoppingProductAd.getAllFields().toString());


entryList.add(entry);
}
Would you be able to help with this? 
Thank you!




Message has been deleted

Google Ads API Forum Advisor Prod

unread,
Aug 20, 2020, 11:33:26 AM8/20/20
to ahme...@gmail.com, adwor...@googlegroups.com
Hi Ahmed,

Please try to update the following lines:

AdGroupAd adGroupAd =googleAdsRow.getAdGroupAd();
Ad ad = adGroupAd.getAd();
to
Ad ad = googleAdsRow.getAdGroupAd().getAd();

Ahmed Adly

unread,
Aug 20, 2020, 1:55:26 PM8/20/20
to Google Ads API Forum Advisor Prod, adwor...@googlegroups.com
Hello Anthony,
I tried that and still the same. the code now looks like this: 


Ad ad = googleAdsRow.getAdGroupAd().getAd();
ShoppingProductAdInfo shoppingProductAd = googleAdsRow.getAdGroupAd().getAd().getShoppingProductAd();

System.out.println(shoppingProductAd.toString());

I tried this version as well with no success

Ad ad = googleAdsRow.getAdGroupAd().getAd();
ShoppingProductAdInfo shoppingProductAd = ad.getShoppingProductAd();

System.out.println(shoppingProductAd.toString());
Appreciate your help.

Thank you

Reply all
Reply to author
Forward
0 new messages