Google Ad-Words API - ad extention link for mobile

85 views Asked by At

During adding site links to campaign feed, I would like to set device preference for mobile to be checked. How can I do it with ad words API ?

platformOperand.stringValue = "Mobile";//it also can be set for "Desktop"

I tried to do it like this:

ConstantOperand platformOperand = new ConstantOperand();
platformOperand.stringValue = "Mobile";//it also can be set for "Desktop"
platformOperand.type = ConstantOperandConstantType.STRING;

Function platformFunction = new Function();
platformFunction.lhsOperand = new FunctionArgumentOperand[] { 
platformRequestContextOperand };
platformFunction.@operator = FunctionOperator.EQUALS;
platformFunction.rhsOperand = new FunctionArgumentOperand[] { 
platformOperand };

and then it combined in function with links ids from google service and mutated for campaign feed service. No exception and link added but when I enter to link edit, "Mobile" option remain unmarked.

enter image description here

Please advise.

1

There are 1 answers

0
Dima On

I found the answer: you shuld set devicePreference when you set propertes for FeedItem:

// Create the feed item and operation.
        var item = new FeedItem();
        item.feedId = siteLinksData.SiteLinksFeedId;
        item.attributeValues = new FeedItemAttributeValue[]   
      {linkTextAttributeValue, linkUrlAttributeValue };
        if (value.DeviceType == Device.Mobile)
        {
            item.devicePreference = new FeedItemDevicePreference();
            item.devicePreference.devicePreference = 30001L;
            item.devicePreference.devicePreferenceSpecified = true;
        }

and this is most important part:

item.devicePreference = new FeedItemDevicePreference();
item.devicePreference.devicePreference = 30001L;
item.devicePreference.devicePreferenceSpecified = true;

if you wondering what the meaning of 30001L, it's device criteria IDs according to adwords API See https://developers.google.com/adwords/api/docs/appendix/platforms