オフラインコンバージョン

Googleスプレッドシートからオフラインコンバージョン情報をアップロード処理(スプレッドシートIDを指定)


function uploadSpreadSheetData(){
  const accountId = AdsUtilities.getCurrentAccountId();
  const SPREAD_SHEET_ID = '111112222233333AAAABBBBBCCCCC';
  const SPREAD_SHEET_NAME = 'sheetName';
  const spreadSheet = SpreadsheetApp.openById(SPREAD_SHEET_ID);
  const sheet = spreadSheet.getSheetByName(SPREAD_SHEET_NAME);
  const dataArray = sheet.getDataRange().getValues();
  // Load the spreadsheet and format it as CSV (Shift_JIS)
  let fileContent = '';
  dataArray.forEach(row => {
    fileContent += row + '\n';
  });
  fileContent = Utilities.newBlob("").setDataFromString(fileContent, "Shift_JIS").getBytes();
  // File upload
  const offlineConversions = Search.OfflineConversionService.upload(
    accountId,
    'NEW',
    'uploadSpreadSheetName',
    fileContent
  ).rval;
}