Getting criterion ID for one keyword

41 views
Skip to first unread message

Filip Pećanac

unread,
Nov 15, 2021, 12:40:44 PM11/15/21
to AdWords API and Google Ads API Forum
Hi,

When I run GetKeywords.php it displays info about all criterion keywords.

So, how should I structure my GAQL query when I want to get just the criterion ID for only one keyword that I have previously added?

Thanks in advance!

Regards,
Filip


Google Ads API Forum Advisor

unread,
Nov 15, 2021, 10:35:53 PM11/15/21
to filip....@oneassessment.com, adwor...@googlegroups.com
Hi Filip,

If you have enabled logging, the complete resource name (including the ID of the keyword) of your keyword that had just been created via the API should be returned in the response logs. Otherwise, you would need to use the change_event service to retrieve details of the most recent changes you performed in your account.

Best regards,

Reminder: Share your feedback about the Google Ads (AdWords) API! Take the 2021 Google Ads API and AdWords API Annual Survey
 
Google Logo
Peter Laurence Napa Oliquino
Google Ads API Team
 


ref:_00D1U1174p._5004Q2R9C3r:ref

Filip Pećanac

unread,
Nov 16, 2021, 5:41:36 AM11/16/21
to AdWords API and Google Ads API Forum
Hi Peter,

Thanks for the reply, but I think you have misunderstood me :)

In the library there is GetKeywords.php example file which retrieves all keywords for specific Ad Group. The query used in this example is:

$query =
'SELECT ad_group.id, '
. 'ad_group_criterion.type, '
. 'ad_group_criterion.criterion_id, '
. 'ad_group_criterion.keyword.text, '
. 'ad_group_criterion.keyword.match_type '
. 'FROM ad_group_criterion '
. 'WHERE ad_group_criterion.type = KEYWORD';
if ($adGroupId !== null) {
$query .= " AND ad_group.id = $adGroupId";

As I don't have previous experience with GAQL, could you please advice how should i modify this query to get the ID of a certain word? I suppose the word should be used in the WHERE part but i am just unsure how to include it.

Thanks in advance!

Regards,
Filip

Google Ads API Forum Advisor

unread,
Nov 16, 2021, 10:11:36 AM11/16/21
to filip....@oneassessment.com, adwor...@googlegroups.com
Hi Filip,

If you want to get the ID of a keyword by keyword text, you can use the following query:

SELECT ad_group_criterion.criterion_id, ad_group_criterion.keyword.text, ad_group_criterion.type FROM ad_group_criterion WHERE ad_group_criterion.type = 'KEYWORD' AND ad_group_criterion.keyword.text = 'Your Keyword Text'

You can use the Query Builder for help with constructuring queries.

Regards,
Matt
Google Ads API Team



Reminder: Share your feedback about the Google Ads (AdWords) API! Take the 2021 Google Ads API and AdWords API Annual Survey
 
Google Logo
Matt
Google Ads API Team
 


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