This is the legacy documentation for Google Ads scripts. Go to the current docs.

Ad Customizers

Stay organized with collections Save and categorize content based on your preferences.

Create an ad customizer data source

function createAdCustomizerSource() {
      .addAttribute('flower', 'text')
      .addAttribute('price', 'price')

Find an ad customizer data source by name

function getAdCustomizerSource() {
  var sources = AdsApp.adCustomizerSources().get();
  while (sources.hasNext()) {
    var source =;
    if (source.getName() == 'Flowers') {
      Logger.log(source.getName() + ' ' + source.getAttributes());

Get a data source's customizer items

function getAdCustomizerItems() {
  var source = AdsApp.adCustomizerSources().get().next();
  var items = source.items().get();
  while (items.hasNext()) {
    var item =;

Create ad customizers

function createAdCustomizers() {
  var source = AdsApp.newAdCustomizerSourceBuilder()
      .addAttribute('flower', 'text')
      .addAttribute('price', 'price')
      .withAttributeValue('flower', 'roses')
      .withAttributeValue('price', '$29.99')

Create text ad with ad customizers

function setupCustomizedAd() {
  // If you have multiple ad groups with the same name, this snippet will
  // pick an arbitrary matching ad group each time. In such cases, just
  // filter on the campaign name as well:
  // AdsApp.adGroups()
  //      .withCondition('Name = "INSERT_ADGROUP_NAME_HERE"')
  //      .withCondition('CampaignName = "INSERT_CAMPAIGN_NAME_HERE"')
  var adGroupIterator = AdsApp.adGroups()
      .withCondition('Name = "INSERT_ADGROUP_NAME_HERE"')
  if (adGroupIterator.hasNext()) {
    var adGroup =;

    // This ad will try to fill in the blanks using the 'flower' and 'price'
    // attributes from the 'Flower' data source.
        .withHeadlinePart1('Flowers for sale')
        .withHeadlinePart2('Fresh cut {=Flowers.flower}')
        .withDescription('starting at {=Flowers.price}')