GAQL: Filtering on FinalUrls containing some text

592 views
Skip to first unread message

goingdev

unread,
Dec 28, 2021, 2:58:13 PM12/28/21
to AdWords API and Google Ads API Forum
Question: How do I search keywords which contains specific text in the FinalUrl using GAQL? 

The query builder UI doesn't give an option for using LIKE. It only gives options for CONTAINS ALL, CONTAINS ANY and CONTAINS NONE.

Google Ads API Forum Advisor

unread,
Dec 29, 2021, 1:18:15 AM12/29/21
to ad...@thegoinggroup.com, adwor...@googlegroups.com
Hello,

Thank you for reaching out to us. 

With regard to your concern, please be informed that the LIKE operator is supported on Google Ads Query language. You may want to check our Google Ads Query Language Grammar for more information on this. Also, you may utilize our Google Ads Query Builder tool which checks if your query is valid.

Regards,
Google Logo
Teejay Wennie Pimentel
Google Ads API Team
 

 

ref:_00D1U1174p._5004Q2TldHI:ref

goingdev

unread,
Dec 29, 2021, 9:17:20 AM12/29/21
to AdWords API and Google Ads API Forum
It's not valid for use on the FinalUrls though, as per the error message the API gave me:

LIKE is not a valid operator to use with 'ad_group_criterion.final_urls' in WHERE clause. Valid operators: CONTAINS ALL, CONTAINS ANY, CONTAINS NONE.

As such, please advise how I can search keywords which contain a specific text in the FinalUrl.

Mat

unread,
Dec 29, 2021, 11:11:50 AM12/29/21
to AdWords API and Google Ads API Forum
Hi goingdev,

I guess that the LIKE operator is not valid/available for the field "ad_group_criterion.final_urls", because that field is actually a list of strings, despite of being classed as "STRING" in the reference.

Regards
Mat

goingdev

unread,
Dec 29, 2021, 11:41:43 AM12/29/21
to AdWords API and Google Ads API Forum
Correct. So the question remains:

How do I search keywords which contain a specific text in the FinalUrl? 

With the old Google Adwords, the CONTAINS predicate acted like a LIKE operator, and I was able to successfully search keywords based on a substring within the FinalUrl:
new Predicate{ field = "FinalUrls", @operator = PredicateOperator.CONTAINS, values = new string[]{"/Prd/"}}

However, with the new Google Ads API, using CONTAINS ANY does not search substrings; only complete values of the FinalUrl. The following does not work:
WHERE ad_group_criterion.final_urls CONTAINS ANY ('/Prd/')

Mat

unread,
Dec 29, 2021, 11:56:03 AM12/29/21
to AdWords API and Google Ads API Forum
You don't. 
You'd have to do that on your end (as in iterating through the rows of the response and check the values). Something like this:

        for final_url in row.ad_group_criterion.final_urls:
            if "Prd" in final_url:
                ...

goingdev

unread,
Dec 29, 2021, 12:30:37 PM12/29/21
to AdWords API and Google Ads API Forum
Well if they downgraded and pulled that functionality from the new version, then I don't have a choice. 

But otherwise, ideally for both sides, I would only pull the keywords that I need for the job at hand, instead of querying and looping through some extra couple of thousand keywords unnecessarily.

Zorion

unread,
Dec 30, 2021, 7:27:07 AM12/30/21
to AdWords API and Google Ads API Forum
If you had the list of final urls including the text you are looking for (so all possible URLs in your account including "Prd") you would be able to use CONTAINS_ANY.
Dismiss my comment if that list is not possible to get.

Google Ads API Forum Advisor

unread,
Dec 30, 2021, 8:55:22 PM12/30/21
to zarriz...@g-n.com, adwor...@googlegroups.com
Hi everyone,

As mentioned by Zorion, you should be able to query records with specific strings, using the CONTAINS ANY operator. Let me know how this goes on your end.

Best regards,

Google Logo
Peter Laurence Napa Oliquino
Google Ads API Team
 


ref:_00D1U1174p._5004Q2TldHI:ref

Nelson Brochado

unread,
Mar 16, 2023, 6:38:39 AM3/16/23
to Google Ads API and AdWords API Forum
I'm also having a similar problem. It seems we cannot filter URLs by substrings. For example, if I wanted all rows that contain URLs with substrings ".com" or "/en/", it seems I can't do it, or am I wrong? I would be happy to be wrong, because I need to do this and it would be nice if I don't have to do it in a post-processing step, after having gotten all the unfiltered data.

Google Ads API Forum Advisor

unread,
Mar 16, 2023, 12:03:28 PM3/16/23
to nelson....@webrepublic.ch, adwor...@googlegroups.com
Hi Nelson,

Thank you for raising this concern to the Google Ads API support team.

Regarding your concern, please note that the Google Ads API mirrors the Google Ads UI. Meaning, what can you see in the Google Ads UI can be retrieved and managed by using the Google Ads API. That said, can you please confirm if this is possible in the Google Ads UI? If yes, can you provide the uncropped Google Ads UI screenshot so that our team can provide accurate assistance?

You may then send the requested logs 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.

Additionally, you may check our Google Ads Query Language and Google Ads Query Language Grammar guides for reference.

Regards,
Google Logo Google Ads API Team


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