Hello everyone. A few months ago, we announced <http://googleadsdeveloper.blogspot.com/2015/02/new-callonly-creative-type-in-adwords.html> the new CallOnlyAd <https://developers.google.com/adwords/api/docs/reference/v201502/AdGroupAdService.CallOnlyAd> as a replacement for the existing ONLY placeholder type <https://developers.google.com/adwords/api/docs/appendix/placeholders#call>.
We've had a lot of requests for an example of how this could be accomplished. Here's an image of the web interface to help visualize how the old fields and extensions relate to the fields on the new ad type: <https://lh3.googleusercontent.com/-gZ5r69ZPn2g/VUeycKgfV0I/AAAAAAAAAB4/uuYnEhLM3-4/s1600/callonlymapping.png> In addition, the following Java snippets can help you use the AdWords API to migrate to the new format. You can use this general flow in any of the client libraries; this is just a sample of what migration code might look like and how to map from the old information to the new information. Please note that these are only intended as a guideline and should be amended/extended to the needs and specifics of your platform. Please make sure to take care of additional campaign data (e.g. other extensions, labels). We also recommend to create the new campaigns in paused state and check the results of the migration before activating them/deleting the legacy ones. // These mappings are taken from the placeholders reference page: // https://developers.google.com/adwords/api/docs/appendix/placeholders#call public static final int PHONE_NUMBER = 1; public static final int COUNTRY_CODE = 2; public static final int TRACKED = 3; public static final int CONVERSION_TYPE_ID = 6; // Let's assume the basic objects are there AdWordsServices adWordsServices = ...; AdWordsSession session = ...; // It is up to you to determine the correct feed item for the call // extension you want to migrate. FeedItem feedItem = ...; // This is the feed mapping that you are using for your call extensions. FeedMapping mapping = ...; // We need to make a temporary map to avoid repeatedly searching through // the AttributeFieldMappings array. Map<Long, Integer> placeholderIdMapping = new HashMap<Long, Integer>(); AttributeFieldMapping[] attributeFieldMappings = mapping.getAttributeFieldMappings(); for (int i = 0; i < attributeFieldMappings.length; i++){ placeholderIdMapping.put( attributeFieldMappings[i].getFeedAttributeId(), attributeFieldMappings[i].getFieldId() ); } // This map will map the placeholder ID to the value for this feed item. // This will be useful later when populating the new ad. Map<Integer, Object> placeholderValueMapping = new HashMap<Integer, Object>(); FeedItemAttributeValue[] attributes = feedItem.getAttributeValues(); for (int i = 0; i < attributes.length; i++){ switch (placeholderIdMapping.get(attributes[i].getFeedAttributeId())) { case PHONE_NUMBER: placeholderValueMapping.put(PHONE_NUMBER, attributes[i].getStringValue()); break; case COUNTRY_CODE: placeholderValueMapping.put(COUNTRY_CODE, attributes[i].getStringValue()); break; case TRACKED: placeholderValueMapping.put(TRACKED, attributes[i].getBooleanValue()); break; case CONVERSION_TYPE_ID: placeholderValueMapping.put(CONVERSION_TYPE_ID, attributes[i].getIntegerValue()); break; } } // This is the previous text ad that you want to copy into your new // CallOnlyAd. TextAd previousAd = ...; AdGroupAdServiceInterface adGroupAdService = adWordsServices.get(session, AdGroupAdServiceInterface.class); CallOnlyAd ad = new CallOnlyAd(); ad.setDescription1(previousAd.getDescription1()); ad.setDescription2(previousAd.getDescription2()); ad.setDisplayUrl(previousAd.getDisplayUrl()); ad.setFinalUrls(previousAd.getFinalUrls()); ad.setCountryCode((String) placeholderValueMapping.get(COUNTRY_CODE)); ad.setPhoneNumber((String) placeholderValueMapping.get(PHONE_NUMBER)); ad.setBusinessName("Some name"); ad.setDisableCallConversion(! ((Boolean)placeholderValueMapping.get(TRACKED))); ad.setConversionTypeId((Long)placeholderValueMapping.get(CONVERSION_TYPE_ID )); ad.setPhoneNumberVerificationUrl(previousAd.getDisplayUrl()); // It is up to you to determine the correct ad group where you want // your new ad to reside. AdGroupAd adGroupAd = new AdGroupAd(); adGroupAd.setAdGroupId(...); adGroupAd.setAd(ad); // Set up the operation to send to the API. AdGroupAdOperation operation = new AdGroupAdOperation(); operation.setOperand(adGroupAd); operation.setOperator(Operator.ADD); AdGroupAdOperation[] operations = new AdGroupAdOperation[] {operation}; // Execute the operation and fetch the results. AdGroupAdReturnValue result = adGroupAdService.mutate(operations); After migrating the affected ads to the new “Call Only” format, please think about the next steps: - Pause or remove the original ads / feed items to avoid duplicate content - Amend your implementation for creating those ads in the future to use the new ad type I hope this helps to ease the migration to the new CallOnlyAd! Michael Cloonan, 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 [email protected] To unsubscribe from this group, send email to [email protected] 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 [email protected]. Visit this group at http://groups.google.com/group/adwords-api. To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/fed11154-734e-4d41-9abe-d6e6fd1bf738%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
