Yahoo!広告 スクリプト | Developer Center
English広告表示アセット
・クイックリンクアセットを新規追加する・クイックリンクアセットを編集する
・電話番号アセットを新規追加する
・電話番号アセットを編集する
・テキスト補足アセットを新規追加する
・テキスト補足アセットを編集する
・カテゴリ補足アセットを新規追加する
・カテゴリ補足アセットを編集する
・Googleドライブから画像アセットを新規追加する
・全てのアセットを取得する
クイックリンクアセットを新規追加する
function addQuicklinkAsset() {
const accountId = AdsUtilities.getCurrentAccountId();
const assetArray = [
{
accountId: accountId,
assetData: {
type: 'QUICKLINK',
quickLinkAsset: {
linkText: 'linkText AAA',
description1: 'description1 BBB',
description2: 'description2 CCC',
}
},
finalUrl: 'http://xxxxx.co.jp/aaaaa/bbbbb',
}
];//Multiple selections are possible
const assets = Search.AssetService.add({
accountId: accountId,
operand: assetArray,
}).rval;
for (let i = 0; i < assets.values.length; i++) {
if (assets.values[i].operationSucceeded) {
let asset = assets.values[i].asset;
Logger.log('assetId-> ' + asset.assetId + ' has been added.');
} else {
Logger.log('linkText-> ' + assetArray[i].assetData.quickLinkAsset.linkText +
', description1-> ' + assetArray[i].assetData.quickLinkAsset.description1 +
', description2-> ' + assetArray[i].assetData.quickLinkAsset.description2 + ' could not be added.');
}
}
}
クイックリンクアセットを編集する
function setQuicklinkAsset() {
const accountId = AdsUtilities.getCurrentAccountId();
const assetArray = [
{
accountId: accountId,
assetId: 1111111,
assetData: {
type: 'QUICKLINK',
quickLinkAsset: {
linkText: 'New linkText DDD',
description1: 'New description1 EEE',
description2: 'New description2 FFF',
}
},
finalUrl: 'http://yyyyy.co.jp/ccccc/ddddd',
}
];//Multiple selections are possible
const assets = Search.AssetService.set({
accountId: accountId,
operand: assetArray,
}).rval;
for (let i = 0; i < assets.values.length; i++) {
if (assets.values[i].operationSucceeded) {
let asset = assets.values[i].asset;
Logger.log('assetId-> ' + asset.assetId + ' has been updated.');
} else {
Logger.log('assetId-> ' + assetArray[i].assetId + ' could not be updated.');
}
}
}
電話番号アセットを新規追加する
function addCallAsset() {
const accountId = AdsUtilities.getCurrentAccountId();
const assetArray = [
{
accountId: accountId,
assetData: {
type: 'CALL',
callAsset: {
phoneNumber: '00-0000-0000',
}
}
}
];//Multiple selections are possible
const assets = Search.AssetService.add({
accountId: accountId,
operand: assetArray,
}).rval;
for (let i = 0; i < assets.values.length; i++) {
if (assets.values[i].operationSucceeded) {
let asset = assets.values[i].asset;
Logger.log('assetId-> ' + asset.assetId + ' has been added.');
} else {
Logger.log('phoneNumber-> ' + assetArray[i].assetData.callAsset.phoneNumber + ' could not be added.');
}
}
}
電話番号アセットを編集する
function setCallAsset() {
const accountId = AdsUtilities.getCurrentAccountId();
const assetArray = [
{
accountId: accountId,
assetId: 1111111,
assetData: {
type: 'CALL',
callAsset: {
phoneNumber: '00-0000-0000',
}
}
}
];//Multiple selections are possible
const assets = Search.AssetService.set({
accountId: accountId,
operand: assetArray,
}).rval;
for (let i = 0; i < assets.values.length; i++) {
if (assets.values[i].operationSucceeded) {
let asset = assets.values[i].asset;
Logger.log('assetId-> ' + asset.assetId + ' has been updated.');
} else {
Logger.log('assetId-> ' + assetArray[i].assetId + ' could not be updated.');
}
}
}
テキスト補足アセットを新規追加する
function addCalloutAsset() {
const accountId = AdsUtilities.getCurrentAccountId();
const assetArray = [
{
accountId: accountId,
assetData: {
type: 'CALLOUT',
calloutAsset: {
calloutText: 'New calloutText AAA',
}
}
}
];//Multiple selections are possible
const assets = Search.AssetService.add({
accountId: accountId,
operand: assetArray,
}).rval;
for (let i = 0; i < assets.values.length; i++) {
if (assets.values[i].operationSucceeded) {
let asset = assets.values[i].asset;
Logger.log('assetId-> ' + asset.assetId + ' has been added.');
} else {
Logger.log('calloutText-> ' + assetArray[i].assetData.calloutAsset.calloutText + ' could not be added.');
}
}
}
テキスト補足アセットを編集する
function setCalloutAsset() {
const accountId = AdsUtilities.getCurrentAccountId();
const assetArray = [
{
accountId: accountId,
assetId: 2222222,
assetData: {
type: 'CALLOUT',
calloutAsset: {
calloutText: 'New calloutText BBB',
}
}
}
];//Multiple selections are possible
const assets = Search.AssetService.set({
accountId: accountId,
operand: assetArray,
}).rval;
for (let i = 0; i < assets.values.length; i++) {
if (assets.values[i].operationSucceeded) {
let asset = assets.values[i].asset;
Logger.log('assetId-> ' + asset.assetId + ' has been updated.');
} else {
Logger.log('assetId-> ' + assetArray[i].assetId + ' could not be updated.');
}
}
}
カテゴリ補足アセットを新規追加する
function addCategorySnippetAsset() {
const accountId = AdsUtilities.getCurrentAccountId();
const assetArray = [
{
accountId: accountId,
assetData: {
type: 'STRUCTURED_SNIPPET',
structuredSnippetAsset: {
header: 'タイプ', //指定できる値は次のヘルプページの「補足カテゴリー」列をご覧ください。:https://ads-help.yahoo-net.jp/s/article/H000044718?language=ja
values: ['sample1','sample2','sample3']
}
}
}
];//Multiple selections are possible
const assets = Search.AssetService.add({
accountId: accountId,
operand: assetArray,
}).rval;
for (let i = 0; i < assets.values.length; i++) {
if (assets.values[i].operationSucceeded) {
let asset = assets.values[i].asset;
Logger.log('assetId-> ' + asset.assetId + ' has been added.');
} else {
Logger.log('header-> ' + assetArray[i].assetData.structuredSnippetAsset.header + ' could not be added.');
}
}
}
カテゴリ補足アセットを編集する
function setCategorySnippetAsset() {
const accountId = AdsUtilities.getCurrentAccountId();
const assetArray = [
{
accountId: accountId,
assetId: 222222,
assetData: {
type: 'STRUCTURED_SNIPPET',
structuredSnippetAsset: {
header: 'タイプ', //指定できる値は次のヘルプページの「補足カテゴリー」列をご覧ください。:https://ads-help.yahoo-net.jp/s/article/H000044718?language=ja
values: ['sample A','sample B','sample C']
}
}
}
];//Multiple selections are possible
const assets = Search.AssetService.set({
accountId: accountId,
operand: assetArray,
}).rval;
for (let i = 0; i < assets.values.length; i++) {
if (assets.values[i].operationSucceeded) {
let asset = assets.values[i].asset;
Logger.log('assetId-> ' + asset.assetId + ' has been updated.');
} else {
Logger.log('assetId-> ' + assetArray[i].assetId + ' could not be updated.');
}
}
}
Googleドライブから画像アセットを新規追加する
function addImageAsset() {
const accountId = AdsUtilities.getCurrentAccountId();
const fileId = '12345abcde';
const fileBytes = DriveApp.getFileById(fileId).getBlob().getBytes();
const encoded = Utilities.base64Encode(fileBytes);
const assetArray = [
{
accountId: accountId,
assetData: {
type: 'IMAGE',
imageAsset: {
imageName: 'New image AAA',
data: encoded,
}
}
}
];//Multiple selections are possible
const assets = Search.AssetService.add({
accountId: accountId,
operand: assetArray,
}).rval;
for (let i = 0; i < assets.values.length; i++) {
if (assets.values[i].operationSucceeded) {
let asset = assets.values[i].asset;
Logger.log('assetId-> ' + asset.assetId + ' has been added.');
} else {
Logger.log('imageName-> ' + assetArray[i].assetData.imageAsset.imageName + ' could not be added.');
}
}
}
全てのアセットを取得する
function getAsset() {
const accountId = AdsUtilities.getCurrentAccountId();
const assets = Search.AssetService.get({
accountId: accountId,
}).rval;
if (assets.totalNumEntries == 0) {
Logger.log('Target ID does not exist.');
return;
}
for (let i = 0; i < assets.values.length; i++){
let asset = assets.values[i].asset;
Logger.log('assetId-> ' + asset.assetId + ', type-> ' + asset.assetData.type);
}
}