Create Ad for Adgroup in a "Display Network only" Campaign

85 views
Skip to first unread message

rcard...@gmail.com

unread,
Jun 26, 2017, 6:19:53 AM6/26/17
to AdWords API Forum
Hi,

I'm able to create a "Display Network only" campaign along with the adgroup using an Adword API. Now I want to create Ad from Ad gallery. Attached screenshot will give clear picture.

How Can I achieve this using API.

Thanks,
Prashant More
1.jpg
2.jpg
3.jpg

rcard...@gmail.com

unread,
Jun 26, 2017, 10:14:30 AM6/26/17
to AdWords API Forum
Hi there,

I used following code for adding Ad to a AdGroup.



////////////////////////////////////////////////////////////////////////////////////////////////

const AD_GROUP_ID = '46481580951';

    public static function runExample(AdWordsServices $adWordsServices, AdWordsSession $session, $adGroupId) {
        $adGroupAdService = $adWordsServices->get($session, AdGroupAdService::class);

        // Create the expanded Dynamic Search Ad. This ad will have its headline
        // and final URL auto-generated at serving time according to domain name
        // specific information provided by DynamicSearchAdsSetting at the
        // campaign level.
        $expandedDSA = new ExpandedDynamicSearchAd();
        // Set the ad description.
        $expandedDSA->setDisplayUrl('www.abc.com');
        $expandedDSA->setFinalUrls(['www.abc.com']);
$expandedDSA->setDescription('Dummy description');

        // Create the ad group ad.
        $adGroupAd = new AdGroupAd();
        $adGroupAd->setAdGroupId($adGroupId);
        $adGroupAd->setAd($expandedDSA);

        // Create the operation.
        $operation = new AdGroupAdOperation();
        $operation->setOperator(Operator::ADD);
        $operation->setOperand($adGroupAd);

        // Create the ad on the server and print some information.
        $result = $adGroupAdService->mutate([$operation]);
        $newAdGroupAd = $result->getValue()[0];
        $expandedDSA = $newAdGroupAd->getAd();
        printf(
                "Expanded Dynamic Search Ad with ID %d and description '%s' was"
                . " added.\n", $expandedDSA->getId(), $expandedDSA->getDescription()
        );
    }

//////////////////////////////////////////////////////////////////////////////

I got 2 error ,

1- EntityNotFound.INVALID_ID @ operations[0].operand.adGroupId; trigger:'AdGroupId: 2147483647',    As my 
const AD_GROUP_ID = '46481580951'; is converted integer.

2- When I modified the XML to overcome above error, I got new error
Uncaught exception 'Google\AdsApi\AdWords\v201705\cm\ApiException' with message '[OperationAccessDenied.OPERATION_NOT_PERMITTED_FOR_AD_GROUP_TYPE @ operations[0].operand.ad;

Can anyone help me out with the issue.

Thanks,
Prashant More

Shwetha Vastrad (AdWords API Team)

unread,
Jun 26, 2017, 3:09:22 PM6/26/17
to AdWords API Forum
Hi Prashant, 

Please see my response below: 
  1. I see that the AdGroupId is changed to the PHP_INT_MAX value. I would suggest that you post this question in the library's issue tracker so they can help you out. 
  2. In v201705 of AdWords API, you can only add features related to Dynamic Search Ads to AdGroups of type SEARCH_DYNAMIC_ADS. Please see this blog post for more details. I'm afraid not all AdTypes in the UI are available in the API. The Ad templates available in AdWords API are provided here. You'll need to create the Dynamic Display Ad in the UI and then use Feed Services to manage the Dynamic Display Ad data using AdWords API.
Regards,
Shwetha, AdWords API Team.

rcard...@gmail.com

unread,
Jun 29, 2017, 9:23:24 AM6/29/17
to AdWords API Forum
Hi Shwetha,

Is there any API which can be used to create Dynamic Display Ads ?

My Requirement is, I just want an image ad Placeholder for displaying item from my feed List which I added through API.

I want to create entire campaign using API without manual intervention.

(Note : Ad in the campaign will have image, title, description, final URL)

Thanks,
Prashant More



Shwetha Vastrad (AdWords API Team)

unread,
Jun 29, 2017, 12:01:42 PM6/29/17
to AdWords API Forum
Hi Prashant, 

The Ad types supported in AdWords API are listed hereTemplate Ads can be used to create Ads in formats other than the built-in AdTypes. I'm afraid not all AdTypes available in the UI are supported in the API. You'll need to create the Dynamic Display Ad in the AdWords UI and use AdWords API to manage the Dynamic Display Ad Data using Feed Services as shown here
Reply all
Reply to author
Forward
0 new messages