【问题标题】:How do I find Google Ads Script method names?如何查找 Google Ads 脚本方法名称?
【发布时间】:2021-12-13 00:49:29
【问题描述】:

我刚刚开始学习 Google Ads 脚本。我在 google 中找到了一个如何使用脚本将 Google Ads 数据导出到 Google 表格的示例,但是在指定我的列时遇到了问题。

代码的第 2 步包含我需要提取的所有列。现在我需要在 Step4 中指定他们的方法名称,并在 Step3 中将“Campaign Type”(列)更改为 Google Ads 报告中的正确名称。

我应该在哪里看这个?谢谢你的建议!

所以起始代码如下所示:

function main() {
 
  //Step 1: Connect Google Ads to the Google Sheet
  var spreadsheetUrl = 'link here';
  var spreadsheet = SpreadsheetApp.openByUrl(spreadsheetUrl);
  var ss = spreadsheet.getSheetByName('Sheet1');
  ss.clear();
 
  //Step 2: Create an array to store the data
  var sheetarray = [['Day', 'Account', 'Customer ID', 'Campaign', 'Ad Group', 'Campaign Type', 'Campaign Subtype', 'Image ad name', 'Currency', 'Clicks', 'Impressions', 'Cost', 'Conversions', 'Video-through conv.', 'Video played to 25%', 'Video played to 50%', 'Video played to 75%', 'Video played to 100%', 'Views']];
 
  //Step 3: Collect the data you need from Google Ads
  var keywords = AdsApp.keywords()
      .withCondition("Campaign Type = 'Video'")
      .forDateRange("LAST_30_DAYS")
      .get();
 
  //Step 4: Add the data you got from Google Ads into the array
  while (keywords.hasNext()) {
    var keyword = keywords.next();
    sheetarray.push([
        keyword.getText(),
        keyword.getStatsFor("LAST_30_DAYS").getClicks(),
        keyword.getStatsFor("LAST_30_DAYS").getConversions()
      ]);
  }
   
  //Step 5: Display the contents of the array
  Logger.log(sheetarray);
 
  if (sheetarray.length > 0) {
     
    // Step 6: Send the array's data to the Google Sheet
    ss.getRange(1, 1, sheetarray.length, sheetarray[0].length).setValues(sheetarray);
     
    // Step 7: Send email with link to Google Sheet
    MailApp.sendEmail("a@gmail.com", "Keywords with 'Video' Campaign Type", "Here's the link: "+spreadsheetUrl);
  }
   
}

【问题讨论】:

    标签: google-ads-script


    【解决方案1】:

    你可以使用 appendRow

    ss.appendRow(sheetarray);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-17
      • 2022-11-21
      • 1970-01-01
      • 2012-05-19
      相关资源
      最近更新 更多