Using AdGroupAdOperation 'SET' instead of Add

239 views
Skip to first unread message

Peter Crowley

unread,
Jan 27, 2012, 10:39:09 AM1/27/12
to AdWords API Forum
I got my token (after 4 months! - I think Anash helped get me across
the line, thx).
My app is published to the live system after a few tweaks - Hurray!

I have a question about whether you can use SET in AdGroupAdOperation
rather then ADD when updating the content of a textAd?
I made the changes outlined below, the code executes without error but
the ad did not change

I took my 'ADD' code which works fine (but costs 40 units & you have
to delete the old ad), changed the operator to 'SET' and added a id to
$textAd

#### Original 'ADD' code

// Create text ad.
$textAd = new TextAd();
$textAd->headline = 'My headline';
$textAd->description1 = 'description 1';
$textAd->description2 = 'description 2';
$textAd->displayUrl = 'www.example.com';
$textAd->url = 'http://www.example.com';

// Create ad group ad.
$textAdGroupAd = new AdGroupAd();
$textAdGroupAd->adGroupId = 123456789;
$textAdGroupAd->ad = $textAd;
$textAdGroupAd->status = 'ENABLED';

// Create operations.
$operation = new AdGroupAdOperation();
$operation->operand = $textAdGroupAd;
$operation->operator = 'ADD';

#### New 'SET' variant

// Create text ad.
$textAd = new TextAd();
$textAd->id = 987654321;
$textAd->headline = 'My headline';
$textAd->description1 = 'description 1';
$textAd->description2 = 'description 2';
$textAd->displayUrl = 'www.example.com';
$textAd->url = 'http://www.example.com';

// Create ad group ad.
$textAdGroupAd = new AdGroupAd();
$textAdGroupAd->adGroupId = 123456789;
$textAdGroupAd->ad = $textAd;
$textAdGroupAd->status = 'ENABLED';

// Create operations.
$operation = new AdGroupAdOperation();
$operation->operand = $textAdGroupAd;
$operation->operator = 'SET';

These 2 URLS only give the lightest information
http://code.google.com/apis/adwords/docs/reference/latest/AdGroupAdService.TextAd.html
http://code.google.com/apis/adwords/docs/reference/latest/AdGroupAdService.AdGroupAd.html
Is there anywhere with more complete docmentation?

Evgeniy Bogdanov

unread,
Jan 27, 2012, 12:03:14 PM1/27/12
to AdWords API Forum
Seems that my message is lost< if not - sorry for double :)

Hi Peter.
Glad to hear that your project is live now. :)

About your question.
Please, read carefully this
http://code.google.com/intl/en/apis/adwords/docs/reference/latest/AdGroupAdService.html#mutate
I'll quote here for you:
"Set - Updates an ad group ad. Except for status, ad group ad fields
are not mutable. Status updates are straightforward - the status of
the ad group ad is updated as specified. If any other field has
changed, it will be ignored. If you want to change any of the fields
other than status, you must make a new ad and then delete the old
one."

So your way with SET will not work.

If you want to save API units - you better to take a look (and use)
MutateJobService.
On a lot of ads you will get a headache with cost and speed of update.
Using this service will help you to save nerves and your money.

Regards,
Evgeniy,

Evgeniy Bogdanov

unread,
Jan 27, 2012, 11:34:09 AM1/27/12
to AdWords API Forum
Hi Peter.

Glad to hear that your application is live now :)

Please, read carefully specification -
http://code.google.com/intl/en/apis/adwords/docs/reference/latest/AdGroupAdService.html#mutate
I'll quote here for you:
"Set - Updates an ad group ad. Except for status, ad group ad fields
are not mutable. Status updates are straightforward - the status of
the ad group ad is updated as specified. If any other field has
changed, it will be ignored. If you want to change any of the fields
other than status, you must make a new ad and then delete the old
one."

So you can't update ad with you way.

I do not remeber if I've told you - but in your case you should use
Bulk operation service (MutateJobService) in v201109.
While you've 10-100 ads your way is good, but when count of ads will
grow you will get a lot of problems - speed of update and total bill
will be not good. :)

Regards,
Evgeniy.
> These 2 URLS only give the lightest informationhttp://code.google.com/apis/adwords/docs/reference/latest/AdGroupAdSe...http://code.google.com/apis/adwords/docs/reference/latest/AdGroupAdSe...

Peter Crowley

unread,
Jan 27, 2012, 1:22:22 PM1/27/12
to AdWords API Forum
Thanks for the quick response.
I had not seen that page.
All is working again - my 'messing' arose, because I was not REMOVEing
the old ad before ADDing the new one.

I am actually already using GetBulkMutateJobService.
Someone not to far from you (in Russian terms!) helped me out using
the example code as a starting point.

громне спасибо!

-Peter

On Jan 27, 4:34 pm, Evgeniy Bogdanov <bogda...@tagan.ru> wrote:
> Hi Peter.
>
> Glad to hear that your application is live now :)
>
> Please, read carefully specification -http://code.google.com/intl/en/apis/adwords/docs/reference/latest/AdG...
> > These 2 URLS only give the lightest informationhttp://code.google.com/apis/adwords/docs/reference/latest/AdGroupAdSe......

Evgeniy Bogdanov

unread,
Jan 27, 2012, 3:02:55 PM1/27/12
to AdWords API Forum
Yes, Alex is really good.

BulkMutateJobService is marked to deprecation, you need to move your
code for use new service MutataJobService.

Regards,
Evgeniy.
Reply all
Reply to author
Forward
0 new messages