Need example code to set PLA Auto Target for AdGroup

116 views
Skip to first unread message

road11

unread,
Apr 18, 2013, 11:58:32 AM4/18/13
to adwor...@googlegroups.com
We've got a PLA campaign with serveral thousand adgroups in it. I need to programatically set the "Auto Target" feature through the API. No idea how to do this. The object browser in Visual Studio can't find anything called an AutoTarget. I saw that a guy back in 2010 had a similar issue, but I can't deduce from his code how this is done, and the Google guy who responded said he didn't have any example code for it back then. Hoping somebody has some now.

Can somebody please paste some C# (I'd even settle for a Java example at this point) of how to set an auto target value on an adgroup?

Thank you, thank you, thank you in advance. 

road11

unread,
Apr 23, 2013, 7:20:05 AM4/23/13
to adwor...@googlegroups.com
Since no one else has answered, and I've figured it out, I thought I'd post my solution here. Hope this helps somebody...

            long adGroupID = 123456789;
            AdWordsUser user = new AdWordsUser();
            AdGroupCriterionService adGroupCriterionService =
               (AdGroupCriterionService)user
               .GetService(AdWordsService.v201302.AdGroupCriterionService);
            
            ProductCondition[] pcs = new ProductCondition[1];
            ProductCondition pc = new ProductCondition();
            pc.operand = new ProductConditionOperand();
            pc.operand.operand = "id";
            pc.argument = "ABC123";
            pcs[0] = pc;
 
            Product p = new Product();
            p.conditions = pcs;
            
            BiddableAdGroupCriterion pgc = new BiddableAdGroupCriterion();
            pgc.adGroupId = adGroupID;
            pgc.criterion = p;
 
            AdGroupCriterionOperation aop = new AdGroupCriterionOperation();
            aop.@operator = Operator.ADD;
            aop.operand = pgc;
 
            AdGroupCriterionOperation[] aops = new AdGroupCriterionOperation[1];
            aops[0] = aop;
 
            adGroupCriterionService.mutate(aops); //magic happens here


Reply all
Reply to author
Forward
0 new messages