How to filter the Campaign Performance Report based on where condition

96 views
Skip to first unread message

Anurag Sinha

unread,
Aug 31, 2021, 12:47:17 AM8/31/21
to AdWords API and Google Ads API Forum
Hi Team,  
I wanted to filter the  Campaign Performance Report based on CampaignId, Can you please let me know how to do it?
ReportQuery query =
        new ReportQuery.Builder()
            .fields(
                "CampaignId",
                "CampaignName")
            .from(ReportDefinitionReportType.CAMPAIGN_PERFORMANCE_REPORT)
         //   .where("Status").in("ENABLED", "PAUSED")
           // .during(ReportDefinitionDateRangeType.LAST_7_DAYS)
                .where("CampaignId").contains("78945612")
            .build();

It gives an error as :
Report was not downloaded due to a DetailedReportDownloadResponseException with errorText '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><reportDownloadError><ApiError><type>SelectorError.INVALID_PREDICATE_OPERATOR</type><trigger>CampaignId</trigger><fieldPath>selector.reportDefinition.selector</fieldPath></ApiError></reportDownloadError>', trigger 'CampaignId' and field path 'selector.reportDefinition.selector'


Regards,
Anurag Sinha

Google Ads API Forum Advisor

unread,
Aug 31, 2021, 3:13:16 AM8/31/21
to anuragku...@in.pega.com, adwor...@googlegroups.com
Hi Anurag,

When using the CampaignId (Long) as a predicate you should use other operators such as "=". This is because operators such as CONTAINS are designed more for string values.

I hope this helps.

Best regards,

Google Logo
Peter Laurence Napa Oliquino
Google Ads API Team
 


ref:_00D1U1174p._5004Q2Mk98O:ref

Anurag Sinha

unread,
Aug 31, 2021, 8:07:10 AM8/31/21
to AdWords API and Google Ads API Forum
Hi Team,
Thanks for quick response.
I tried the suggested approach but it does not do a filter based on CampaignId instead it return all the Campaigns.

ReportQuery query =
        new ReportQuery.Builder()
            .fields(
                "CampaignId",
                "CampaignName")
            .from(ReportDefinitionReportType.CAMPAIGN_PERFORMANCE_REPORT)
         //   .where("Status").in("ENABLED", "PAUSED")
           // .during(ReportDefinitionDateRangeType.LAST_7_DAYS)
                .where("CampaignId").equalTo(6299310791)
            .build();

Regards,
Anurag Sinha

Google Ads API Forum Advisor

unread,
Sep 2, 2021, 9:50:52 AM9/2/21
to anuragku...@in.pega.com, adwor...@googlegroups.com
Hello,

Can you please provide us with your customer ID so that we can take a closer look at the issue you're having?

Thanks,
Matt
Google Ads API Team

Google Logo
Matt
Google Ads API Team
 


ref:_00D1U1174p._5004Q2Mk98O:ref

Anurag Sinha

unread,
Sep 3, 2021, 6:14:29 AM9/3/21
to AdWords API and Google Ads API Forum
Hi Team, 
Thanks for the quick Response.

I am using CampaignCriterionServiceInterface for my Use Case., where I can to a filter on a specific CampaignId but I wanted to do a filter and get the results for a set of CampaignIDs
and I tried both containsAny and containsAll. Both of them gives exception  "<message>[SelectorError.INVALID_PREDICATE_OPERATOR @ serviceSelector; trigger:'CampaignId']</message>"
And the selector which I created is as below:
 CampaignCriterionServiceInterface campaignCriterionService = adWordsServices.get(session,CampaignCriterionServiceInterface.class);
    SelectorBuilder builder = new SelectorBuilder();
    Selector selector = builder.fields("CampaignId","UserListName","UserListId")
            .equals("CriteriaType",CriterionType._USER_LIST)
            .equals("IsNegative","false")
           // .equals("CampaignId","11614823499")
            //.containsAll()
            .containsAny("CampaignId","11614823","113245217","116130924")
            .offset(offset).limit(PAGE_SIZE).build();

Can you please let me know how can I use multiple CampaignID at Same time?

Regards,
Anurag Sinha

Google Ads API Forum Advisor

unread,
Sep 7, 2021, 6:20:18 AM9/7/21
to anuragku...@in.pega.com, adwor...@googlegroups.com
Hi Anurag,

Thank you for your follow up.

Regarding using the = or equalTo operator, you mentioned "I tried the suggested approach but it does not do a filter based on CampaignId instead it return all the Campaigns.", it would be unlikely that all campaigns would be returned if the condition was used correctly in the said query.

Moving forward to your other request, now using the CampaignCriterionService. For retrieving details based on a group of campaignIds, I would recommend that you use the IN operator instead of Contains Any.

Should issues persist in your CampaignCriterionService request, you may provide the complete SOAP request and response logs, with the requestId. On the other hand, if you continue to encounter issues with your reporting requests, you may then provide the complete report definition in XML or AWQL form.

The above requested details should then help our team to further troubleshoot the issues.

Best regards,

Google Logo
Peter Laurence Napa Oliquino
Google Ads API Team
 


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