Script to pull pricing from Google Sheets to update ad customizer attributes for RSA

215 views
Skip to first unread message

Dan Jones

unread,
Apr 14, 2023, 7:25:08 AM4/14/23
to Google Ads Scripts Forum
I have a script that will pull updated pricing from Google Sheets and I'd like to place it in the Ad customizer attributes for RSA, but I can only find documentation for updating the old ad customizer data for ETA.

 Our pricing changes daily so I'd like to not have to do this manually every day.

This is my script so far. I just don't know how to get the data into the ad customizer attributes for RSA.

function main() {
  var SPREADSHEET_URL = "https://docs.google.com/spreadsheets/d/1gvfoa2OMqpLOUrRm8jrLItqDKRpa793V6Kp3BQEKMR0/edit?usp=sharing";
  var SHEET_NAME = "Accent-on-Decatur-Price";
  var ATTRIBUTE_NAMES = ["Studio", "1 Bedroom", "2 Bedroom"];
  var ATTRIBUTE_DATA_TYPE = "Account value";
  var ATTRIBUTE_DEFAULT_VALUE = "Call for pricing";


  var spreadsheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL);
  var sheet = spreadsheet.getSheetByName(SHEET_NAME);
  var data = sheet.getDataRange().getValues();

  var prices = {};

 
  for(let i=0; i< data.length; i++){
   console.log('data', data[i]);
  }
 
  for(const source of AdsApp.adCustomizerSources()){
    console.log(source.getAttributes())
    
  }
}


Google Ads Scripts Forum Advisor

unread,
Apr 14, 2023, 9:24:55 AM4/14/23
to adwords...@googlegroups.com

Hi Dan,

 

Thanks for reaching out to the Google Ads Scripts Team.

 

You could check our documentation on Ad Customizers for more information on the available methods which can be used in Google Ads Scripts. However, if you're looking for another feature that is not stated in our documentation, could you please further elaborate on what you're aiming for in bullet form so we're able to have a better understanding of your concern? Complete and uncropped screenshots are very much appreciated.

 

You may send these privately via the Reply to author option. Note that you may need to join the Google Group for you to use this option. If this option is not available on your end still, you may send it through our email (googleadsscr...@google.com) instead.

 

Relevant links:

 

Best regards,

 

Google Logo Google Ads Scripts Team


ref:_00D1U1174p._5004Q2kVVNU:ref

Sigurd Fabrin

unread,
Apr 18, 2023, 8:03:03 AM4/18/23
to Google Ads Scripts Forum
Hi Dan,

It also took me a while to figure out. RSA ad customizers are a completely different beast.

So, if your ad has this content: {CUSTOMIZER.one:This is the fallback text}, {CUSTOMIZER.twoThis is another fallback text} etc
Then create a spreadsheet where you write the actual values for these customizers for each campaign/adGroup/keyword combination you use. And then add it to the account using bulk upload either via a script or scheduled.

Like this:
Campaign, Ad group, Customizer:One, Customizer:Two
campaign_1,adGroup_1, "X-product €100", "April 18 sale"
campaign_1,adGroup_2, "Y-product €200", "April 18 sale"
campaign_1,adGroup_3, "Z-product €300", "April 18 sale"


sigurd

Dan Jones

unread,
Apr 18, 2023, 10:41:30 AM4/18/23
to Google Ads Scripts Forum
Sigurd,

Thank you so much for digging into this. We will try this out.

Google Ads Scripts Forum

unread,
Apr 20, 2023, 4:34:12 AM4/20/23
to Google Ads Scripts Forum
Reposting the last inquiry (https://groups.google.com/g/adwords-scripts/c/IF6sIWnoJKw) from the forum as it wasn't routed to our support queue.

Regards,
Google Ads Scripts Team

Google Ads Scripts Forum

unread,
Apr 20, 2023, 6:08:45 AM4/20/23
to Google Ads Scripts Forum

Hi All,

@Sigurd - Thank you for your continued patronage to this public forum.

@Dan - I believe Sigurd's recommendation is a great approach to follow. In the event that you'd need further assistance or encounter any errors, please let us know along with your Google Ads account ID or CID as well as the name of the script in your account so our team can further investigate.

Best regards,
Google Ads Scripts Team

Visie Tubban

unread,
Apr 20, 2023, 3:01:54 PM4/20/23
to Google Ads Scripts Forum
I was wondering if you could send me more details

--
-- You received this message because you are subscribed to the Google Groups AdWords Scripts Forum group. Please do not reply to this email. To post to this group or unsubscribe please visit https://developers.google.com/adwords/scripts/community.
---
You received this message because you are subscribed to the Google Groups "Google Ads Scripts Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-scrip...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/d1645e68-65a2-451a-ae62-1fc36972ff75n%40googlegroups.com.

Dan Jones

unread,
Apr 20, 2023, 4:51:04 PM4/20/23
to Google Ads Scripts Forum
Visie,

My main issue is I’m unable to access AdCustomizerItems to be able to set the attribute values. No sources are returned by AdsApp.adCustomizerSources() so I don’t think I can retrieve an item to update the attributes. Is there a way to directly access an AdCustomizerItem? 

Let me know if you need other details.

This is our current code:

function main() {

 

  // retrieve spreadsheet data


  var spreadsheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL);
  var sheet = spreadsheet.getSheetByName(SHEET_NAME);
  var data = sheet.getDataRange().getValues();

  // store desired data


  var prices = {};
  for(let i=0; i< data.length; i++){

    if(ATTRIBUTE_NAMES.includes(data[i][0])){
     prices[data[i][0]] = data[i][2];
    }
  }

 


  // loop through sources
  for(const source of AdsApp.adCustomizerSources()){

    console.log('Source', source.getName());

    // retrieve items
    var adCustomizerItemSelector = source.items();

 

    var adCustomizerItemIterator = adCustomizerItemSelector.get();
    while (adCustomizerItemIterator.hasNext()) {
      var adCustomizerItem = adCustomizerItemIterator.next();
      console.log('item', adCustomizerItem);

      // adCusotmizerItem.setAttributes(prices)
    }
  }

 

  

}


Google Ads Scripts Forum

unread,
Apr 21, 2023, 6:07:33 AM4/21/23
to Google Ads Scripts Forum
Reposting the last inquiry (https://groups.google.com/g/adwords-scripts/c/IF6sIWnoJKw) from the forum as it wasn't routed to our support queue.

Regards,
Google Ads Scripts Team

Google Ads Scripts Forum Advisor

unread,
Apr 21, 2023, 8:28:50 AM4/21/23
to adwords...@googlegroups.com

Hi Dan,

 

Thank you for providing more context to your use-case. Would you be so kind as to provide your Google Ads account ID or CID as well as the name of the script in the account for our team's further investigation?

 

We'll be looking forward to your response.

Dan Jones

unread,
Apr 28, 2023, 5:50:06 PM4/28/23
to Google Ads Scripts Forum
Google Ads account ID is  666-615-0623

The name of the script is Update Pricing

Thanks,

Dan Jones

Google Ads Scripts Forum

unread,
May 3, 2023, 3:00:29 AM5/3/23
to Google Ads Scripts Forum
Reposting the last inquiry (https://groups.google.com/g/adwords-scripts/c/IF6sIWnoJKw) from the forum as it wasn't routed to our support queue.

Regards,
Google Ads Scripts Team

Google Ads Scripts Forum Advisor

unread,
May 3, 2023, 6:51:07 AM5/3/23
to adwords...@googlegroups.com

Hi Dan,

Thank you for your response. Please be informed that this issue has already been raised to our wider team. We'll update you on this thread as soon as we have information.

Regards,

Mindaugas Jakutis

unread,
Jun 20, 2024, 12:00:31 PM (13 days ago) Jun 20
to Google Ads Scripts Forum
Could anyone update me on this issue as well?
Reply all
Reply to author
Forward
0 new messages