Tuesday, 26 July 2016

Re: Get Current Keywords Bid

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.



Il giorno lunedì 25 luglio 2016 21:17:27 UTC+2, Vishal Vinayak (Adwords API Team) ha scritto:
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

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups "AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/c7836951-b8ad-4d12-adc5-4fd0a119f29e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment