Get Current Keywords Bid

418 views
Skip to first unread message

Ale E.

unread,
Jul 25, 2016, 11:51:34 AM7/25/16
to AdWords API Forum
Hi to Everyone,

i'm new in the Adwords API field and i getting really confused on a subject that i think it's really really easy, i decided to ask here cause after 3 hours of research i didn't find a solution.

My question is, can someone provide me a snippet of .net code to get the current bid of the keywords within a given adgroup?

In the documentation i've been able to find a lot of useful resources but not what i need:


Thank you very much for your help

Vishal Vinayak (Adwords API Team)

unread,
Jul 25, 2016, 3:17:27 PM7/25/16
to AdWords API Forum
Hi Ale,

You can use the AdGroupCriterionService to get the bid of keywords in an ad group. The get keywords example link that you shared has the required code snippet. You can essentially pass the required field names (i.e. CpcBid, CpmBid etc.) in the Selector object to retrieve the values of those particular fields.

Alternatively, you can also use the Keyword Performance Report to get the current bid of keywords. The CpcBid and CpmBid fields of the report returns the respective bids of keywords. 

Regards,
Vishal, AdWords API Team

Ale E.

unread,
Jul 26, 2016, 3:12:51 AM7/26/16
to AdWords API Forum
Hi Vishal,

thanks for your help, i think i got it, i write here what i found out cause there's a little tricky step further to get the job done ( if i've understood correctly ).

The tricky part (or at least what i was not getting) is that you need to cast the object you get from the adGroupCriterionService.get(selector); in order to extract the values you're looking for.

So, to extract the values i needed, here's what i've done ( i'm not sure it's perfect but it seems to work ):

AdGroupCriterionService adGroupCriterionService = (AdGroupCriterionService)user.GetService(AdWordsService.v201605.AdGroupCriterionService);

            Selector selector = new Selector()
            {
                fields = new string[] { CpcBid.Fields.CpcBid, Criterion.Fields.Id, AdGroupCriterion.Fields.AdGroupId, Keyword.Fields.KeywordText },
                predicates = new Predicate[] {Predicate.Equals(Criterion.Fields.Id, keywordId)},
                paging = Paging.Default
            };

AdGroupCriterionPage page = new AdGroupCriterionPage();

            try
            {
                do
                {
                    page = adGroupCriterionService.get(selector);

                    if (page != null && page.entries != null)
                    {
                        int i = selector.paging.startIndex;

                        foreach (AdGroupCriterion adGroupCriterion in page.entries)
                        {
                            string id = ((BiddableAdGroupCriterion)adGroupCriterion).criterion.id.ToString();
                            string Groupid = ((BiddableAdGroupCriterion)adGroupCriterion).adGroupId.ToString();
                            string keyword = ((Keyword)((BiddableAdGroupCriterion)adGroupCriterion).criterion).text;
                            string bid = ((CpcBid)((BiddableAdGroupCriterion)adGroupCriterion).biddingStrategyConfiguration.bids[0]).bid.microAmount.ToString();
....
....

Hope this will help someone that is struggling like me.

Vishal Vinayak (Adwords API Team)

unread,
Jul 26, 2016, 1:32:10 PM7/26/16
to AdWords API Forum
Hi Ale,

This looks correct. Just that the casting to string type might not be explicitly needed. Also, I would recommend using the long datatype for bid.  
Reply all
Reply to author
Forward
0 new messages