AdWords
2.3K members online now
2.3K members online now
Dive into advanced features like Remarketing, Flexible Bid Strategies, AdWords Editor, and AdWords Scripts
Guide Me
star_border
Reply

Script Issue - Inventory-based Ad Management

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Greetings,

 

I've been struggling to customize Google's Inventory-Based Ad Management script. I think it does some great things, but I'm not able to add new columns... 

https://developers.google.com/adwords/scripts/docs/solutions/inventory-management

 

That is the script I'm using, and once I try to add a new dynamic field (column to the spreadsheet), the script says:

  "The attribute you are trying to use (specs) does not exist."

 

I have followed the steps from the "Add new dynamic fields" guidelines from the script documents, but to no avail. Has anyone had any luck with this? Maybe I'm missing something.

 

1. I delete ad customizer Ad from my AdWords UI (with label Discounts)

2. I update createAdCustomizerSource method with "specs"

 

function createAdCustomizerSource() {
Logger.log('Creating a new ad customizer source for discounts...');

if (AdWordsApp.getExecutionInfo().isPreview()) {
Logger.log('This step won\'t work with preview mode, and your script may ' +
'fail at a later stage. Try running this script normally.');
}

var source = AdWordsApp.newAdCustomizerSourceBuilder()
.withName(CUSTOMIZER_SOURCE_NAME)
.addAttribute('code', 'text')
.addAttribute('coupon', 'text')
.addAttribute('discount', 'number')
.addAttribute('name', 'text')
.addAttribute('specs', 'text')
.build().getResult();

 

Logger.log('Done');

return source;
}

 

3. I update the updateAdCustomizerItems method as well:

 

function updateAdCustomizerItems(source, rules) {
Logger.log('Syncing the discount ad customizer source with the ' +
'spreadsheet data...');

var itemMap = {};

// Store the existing ad customizer items into a
// lookup map.
var items = source.items().get();
while (items.hasNext()) {
var item = items.next();
var productCode = item.getAttributeValue('code');
itemMap[productCode] = item;
}

for (var i = 0; i < rules.length; i++) {
// For each rule, see if there's an existing customizer
// item by matching the item code.
var rule = rules[i];
var item = itemMap[rule.code];

if (!item) {
// This is a new item that was added to the spreadsheet.
// Create a new customizer item for this code.
item = source.adCustomizerItemBuilder()
.withAttributeValue('code', rule.code)
.withAttributeValue('discount', rule.discount)
.withAttributeValue('coupon', rule.coupon)
.withAttributeValue('name', rule.name)
.withAttributeValue('specs', rule.specs)
.build()
.getResult();
} else {
// Update this customizer item with the latest details
// from the spreadsheet.
item.setAttributeValue('discount', rule.discount);
item.setAttributeValue('coupon', rule.coupon);
item.setAttributeValue('name', rule.name);
}

 

 

The script can run just fine, but as soon as I try to add the ad customizer for Specs into the expandedTextAdBuilder:

.withHeadlinePart1("New Kia {=Discount.specs}")

 

I get an error:

  "The attribute you are trying to use (specs) does not exist."

 

Has anyone else encountered this?

 

 

Dmitri

1 Expert replyverified_user

Script Issue - Inventory-based Ad Management

Community Manager
# 2
Community Manager

Hi Dmitri,

 

Thanks for reaching out to the AdWords Community. It looks like you have a question concerning the troubleshooting of an AdWords script. For technical discussions with developers and members of the AdWords scripts team, we'd recommend visiting the AdWords Scripts Forum.

 

Hope this helps! 

 

Best,

Akhil