Dynamics Remarketing ads for retail

430 views
Skip to first unread message

Ezequiel Murillo

unread,
Dec 17, 2015, 8:57:48 AM12/17/15
to AdWords API Forum
Hi, 

I want to make dynamic multi-product ads for a Remarketing campaign. It would be for retail so I won't need to use the Feed Service. 
I already have products in my Merchant Center and I've read the references:


The thing is that I'm still not sure how to create the ad. I asume the images, titles and prices would pulled from the Merchant Center, but where would this be specified?
I guess I should use a Template ad, but how would I tell it to pull the template elements from my Merchant Center account?

Thanks, 
I hope I'm just missing something very obvious.

Umesh Dengale

unread,
Dec 17, 2015, 4:08:51 PM12/17/15
to AdWords API Forum
Hello,

You could create the ProductAd using the AdGroupAdService. Please check out the AddShoppingCampaign Java example code from the client library. Other languages code could be found here.

Thanks,
Umesh, AdWords API Team.

Ezequiel Murillo

unread,
Dec 17, 2015, 5:21:48 PM12/17/15
to AdWords API Forum
Sorry, I think I didn't explain myself as I should have. I want to create an ad for a Dynamic Remarketing Campaign in the Display Network, not a Shopping campaign.
I would also like to have a many products in a single ad, so that's what I thought I would need a Template ad, I guess an html5 template ad. 
The type of ad I want to create using the API is like the one explained here:


When I create them using the UI I just choose a template and the images and everything are pulled from my Merchant Center. I'm just not sure how to do that from the API. 
I dont find the one in:
very informative.

Thanks!

Josh Radcliff (AdWords API Team)

unread,
Dec 18, 2015, 3:22:56 PM12/18/15
to AdWords API Forum
Hi,

The AdWords API lets you manage the feed items for dynamic remarketing ads, but it does not support creating the dynamic display ads (with Template Ad ID 416) themselves. Therefore, you'll need to create the ads through the user interface first. After that, you'll be able to use the API to add/remove/update the dynamic data used for those ads.

For more info on managing your feed items for dynamic remarketing ads, check out our Dynamic Remarketing guide.

Thanks,
Josh, AdWords API Team

Ezequiel Murillo

unread,
Dec 18, 2015, 3:55:08 PM12/18/15
to AdWords API Forum
Thanks Josh,

Do you know if there are any plans to add this feature in the not so distant future?

Cheers

Josh Radcliff (AdWords API Team)

unread,
Dec 18, 2015, 4:02:37 PM12/18/15
to AdWords API Forum
Hi,

I can't comment on when or if this feature will be added, but I know there have been other users interested in this as well, so we'll take that into consideration when planning the next release of the AdWords API.

Thanks,
Josh, AdWords API Team

Ezequiel Murillo

unread,
Dec 18, 2015, 4:14:00 PM12/18/15
to AdWords API Forum
Thanks, 

One last silly question!
When you referred to the Template Ad ID 416, did you meant it as an example? I just made a Dynamic Ad for my products, called the ad from the API and it told me it had the Template Ad ID 311. 
I guess the're many templates so, again, sorry for the silly question...I'm just wondering why you would have mentioned a specific Template.


Josh Radcliff (AdWords API Team)

unread,
Dec 18, 2015, 4:21:28 PM12/18/15
to AdWords API Forum
Hi Ezequiel,

Not a silly question at all. :) I just gave that template ID as an example. The user interface lets you create a variety of TemplateAds for dynamic remarketing, but at this time none of them are supported by the API.

Thanks,
Josh, AdWords API Team

Amit P Jivani

unread,
Jun 18, 2018, 4:19:40 PM6/18/18
to AdWords API and Google Ads API Forum
Is this feature available now? 

Josh Radcliff (AdWords API Team)

unread,
Jun 19, 2018, 2:04:33 PM6/19/18
to AdWords API and Google Ads API Forum
Hi,

Although the AdWords API does not support template ID 416, you can now create a ResponsiveDisplayAd for your dynamic remarketing campaigns. The process for doing so will be essentially the same as the createAd step of the Add a Shopping dynamic remarketing campaign example.

Thanks,
Josh, AdWords API Team

Amit P Jivani

unread,
Sep 13, 2018, 4:20:15 AM9/13/18
to AdWords API and Google Ads API Forum
Hi Josh, 

We are trying to upload HTML5 Ad Template for Dynamic Remarketing for Retail. But, it is now showing the preview properly as compared to manual upload of zip file. Can you please help us trouble shoot? 

<?php
/**
 * Copyright 2017 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
namespace Google\AdsApi\Examples\AdWords\v201806\ShoppingCampaigns;
require 'googleads-php-lib-master/vendor/autoload.php';
use Google\AdsApi\AdWords\AdWordsServices;
use Google\AdsApi\AdWords\AdWordsSession;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
use Google\AdsApi\AdWords\v201806\cm\AdGroupAd;
use Google\AdsApi\AdWords\v201806\cm\AdGroupAdOperation;
use Google\AdsApi\AdWords\v201806\cm\AdGroupAdService;
use Google\AdsApi\AdWords\v201806\cm\AdGroupAdStatus;
use Google\AdsApi\AdWords\v201806\cm\Dimensions;
use Google\AdsApi\AdWords\v201806\cm\MediaBundle;
use Google\AdsApi\AdWords\v201806\cm\Operator;
use Google\AdsApi\AdWords\v201806\cm\TemplateAd;
use Google\AdsApi\AdWords\v201806\cm\TemplateElement;
use Google\AdsApi\AdWords\v201806\cm\TemplateElementField;
use Google\AdsApi\AdWords\v201806\cm\TemplateElementFieldType;
use Google\AdsApi\AdWords\v201806\cm\MediaService;
use Google\AdsApi\AdWords\v201806\cm\MediaMediaType;
use Google\AdsApi\Common\MapEntries;
use Google\AdsApi\Common\OAuth2TokenBuilder;
/**
 * This example adds an HTML5 ad to given ad group. To get ad groups, run
 * GetAdGroups.php.
 */
class AddHtml5Ad{
    //const AD_GROUP_ID = '60612836284';
    const AD_GROUP_ID = '58679041196';
    public static function runExample(AdWordsServices $adWordsServices,AdWordsSession $session,$adGroupId) {
        try{   
            $adGroupAdService = $adWordsServices->get($session, AdGroupAdService::class);
            $operations = [];
            // Create a template ad.
            $html5Ad = new TemplateAd();
            $html5Ad->setName('html5');
            // 419 represents uplofadsaded HTML5 bundle. See
            // for details.
            $html5Ad->setTemplateId(419);
            $html5Ad->setFinalUrls(['https://harry-potter-004.myshopify.com']);
            $html5Ad->setDisplayUrl('harry-potter-004.myshopify.com');

            $dimensions = new Dimensions();
            $dimensions->setWidth(160);
            $dimensions->setHeight(600);
            $html5Ad->setDimensions($dimensions);

            // The HTML5 zip file contains all the HTML, CSS, and images needed for the
            // HTML5 ad. For help on creating an HTML5 zip file, check out Google Web
            // Designer (https://www.google.com/webdesigner/).
            //$html5Zip = file_get_contents('https://goo.gl/9Y7qI2');
           // $html5Zip = file_get_contents('http://localhost/google_adword_app/ad/test/300/300.zip');
            $html5Zip = file_get_contents('new/160_600.zip'); 
            
            $mediaBundle = new MediaBundle();
            $mediaBundle->setData($html5Zip);
            //$mediaBundle->setEntryPoint('carousel/index.html');
            $mediaBundle->setType('MEDIA_BUNDLE');


            // Create the template elements for the ad. You can refer to
            // for the list of avaliable template fields.
            $media = new TemplateElementField();
            $media->setName('Custom_layout');
            $media->setFieldMedia($mediaBundle);
            $media->setType(TemplateElementFieldType::MEDIA_BUNDLE);

            $layout = new TemplateElementField();
            $layout->setName('layout');
            $layout->setFieldText('Custom');
            $layout->setType(TemplateElementFieldType::ENUM);

            $adData = new TemplateElement();
            $adData->setUniqueName('adData');
            $adData->setFields([$media, $layout]);

            $html5Ad->setTemplateElements([$adData]);

            // Create ad group ad.
            $adGroupAd = new AdGroupAd();
            $adGroupAd->setAdGroupId($adGroupId);
            $adGroupAd->setAd($html5Ad);
            // Optional: Set additional settings.
            //$adGroupAd->getAd()->setAdType("DYNAMIC_SEARCH_AD");
            $adGroupAd->getAd()->setAdType("THIRD_PARTY_REDIRECT_AD");
            $adGroupAd->setStatus(AdGroupAdStatus::ENABLED);

            // Create ad group ad operation and add it to the list.
            $operation = new AdGroupAdOperation();
            $operation->setOperand($adGroupAd);
            $operation->setOperator(Operator::ADD);
            $operations[] = $operation;

            // Create the ad group ad on the server and print out some information
            // about it.
            $result = $adGroupAdService->mutate($operations);
            foreach ($result->getValue() as $adGroupAd) {
                printf(
                    "New HTML5 ad with ID %d and display URL '%s' was created.\n",
                    $adGroupAd->getAd()->getId(),
                    $adGroupAd->getAd()->getDisplayUrl()
                );
            }
        }
        catch(\Exception $e){
            $msg=$e->getErrors()[0]->getReason();
            print_r($msg);
        }
    }
    public static function main(){
        // Generate a refreshable OAuth2 credential for authentication.
        $oAuth2Credential = (new OAuth2TokenBuilder())
        ->withClientId("ClientIdapp")
        ->withClientSecret("ClientSecret")
        ->withRefreshToken("refreshtoken")
        ->build();
        
        $session = (new AdWordsSessionBuilder())
        ->fromFile('adsapi_php.ini')
        ->withOAuth2Credential($oAuth2Credential)
        ->withClientCustomerId("")
        ->build();
        self::runExample(new AdWordsServices(),$session,intval(self::AD_GROUP_ID));
    }
}
AddHtml5Ad::main();

Josh Radcliff (AdWords API Team)

unread,
Sep 13, 2018, 1:56:45 PM9/13/18
to AdWords API and Google Ads API Forum
Hi Amit,

Could you provide more specifics about what's not working properly when previewing? If you have the ID of a problematic ad, that would be helpful as well.

Thanks,
Josh, AdWords API Team

Amit P Jivani

unread,
Sep 14, 2018, 4:20:28 AM9/14/18
to AdWords API and Google Ads API Forum
Hi Josh, 

Thanks for looking into this. I have replied to you privately. 
Reply all
Reply to author
Forward
0 new messages