SlideShare a Scribd company logo
Google Inc. - All Rights Reserved
MCC スクリプト
JavaScript を使った効率的なアカウント管理
Ryuich Hoshi, Google.
目次
● はじめに
● 使ってみよう
● 参考資料
● Questions?
Google Inc. - All Rights Reserved
はじめに
Google Inc. - All Rights Reserved
● AdWords のデータをプログラムから操作する方法
● JavaScript を使用
● 開発環境は AdWords UI の中に用意
AdWords スクリプトの復習
Script
Google Inc. - All Rights Reserved
function main() {
// AWQL を使って指定した名前のキャンペーンを取得
var demoCampaign = AdWordsApp.campaigns().
withCondition("Name='Demo campaign'").get().next();
// AWQL を使って、直下の広告グループを取得
var demoAdGroup = demoCampaign.adGroups().
withCondition("Name='Demo adgroup'").get().next();
// 広告グループの設定を変更
demoAdGroup.setKeywordMaxCpc(1.2);
}
AdWords スクリプトの復習
Google Inc. - All Rights Reserved
● MCC レベルで使える AdWords スクリプト
● 多くのアカウントを管理可能に
MCC スクリプトとは?
Google Inc. - All Rights Reserved
● 現在は、すべての方がご利用になれます
利用可能な方
Google Inc. - All Rights Reserved
● 1つのスクリプトで複数のアカウントを管理可能
● 1つのスクリプトを複数のアカウントにコピーする必要なし
● 複数のアカウントを並列に処理
利点
Google Inc. - All Rights Reserved
● 管理している全てのアカウントの入札単価を調整
● 複数アカウントのレポートを出力
よくある使い方
Google Inc. - All Rights Reserved
MCC スクリプトを使ってみる
1
2
Google Inc. - All Rights Reserved
使ってみよう
Script
Google Inc. - All Rights Reserved
初めての MCC スクリプト
function main() {
// 全ての子アカウントを取得
var accountIterator = MccApp.accounts().get();
// 取得したアカウントを順に処理
while (accountIterator.hasNext()) {
var account = accountIterator.next();
// 子アカウントのパフォーマンス データを取得
var stats = account.getStatsFor("THIS_MONTH");
// ログに出力
Logger.log("%s,%s,%s,%s", account.getCustomerId(), stats.getClicks(),
stats.getImpressions(), stats.getCost());
}
}
Google Inc. - All Rights Reserved
● アカウントを管理する機能を提供
● 子アカウントを取得
● 操作するアカウントを選択
● 複数のアカウントを並列に処理
MccApp クラス
Google Inc. - All Rights Reserved
var accountIterator = MccApp.accounts().get();
● MccApp.accounts メソッドを使用
● デフォルトでは、全ての子アカウントを返す(サブMCCは除く)
子アカウントを選択する
Script
Google Inc. - All Rights Reserved
● アカウント レベルでフィルターすることが可能
子アカウントを選択する
var accountIterator = MccApp.accounts()
.withCondition('LabelNames CONTAINS "xxx"')
.get();
Script
Google Inc. - All Rights Reserved
● Customer Id を直接指定することも可能
子アカウントを選択する
var accountIterator = MccApp.accounts()
.withIds(['123-456-7890', '345-678-9000'])
.get();
Script
Google Inc. - All Rights Reserved
● デフォルトでは、スクリプトが置かれているアカウント
● MccApp.select を使い、操作対象アカウントを変更
● AdWordsApp クラスを使いアカウントを操作
● 最後に操作対象をMCC アカウントへ戻すことを忘れずに!
いまどのアカウントを操作している?
Script
Google Inc. - All Rights Reserved
var childAccount = MccApp.accounts().withIds(["918-501-8835"])
.get().next();
// 現在のMCCアカウントを保存
var mccAccount = AdWordsApp.currentAccount();
// 子アカウントを選択
MccApp.select(childAccount);
// 子アカウントへの処理を実行
...
// 操作対象を MCC アカウントに戻す
MccApp.select(mccAccount);
特定の子アカウントを操作する
Google Inc. - All Rights Reserved
アカウントを並列に処理する
Google Inc. - All Rights Reserved
● AccountSelector.executeInParallel メソッドを使
用
● 50 アカウントまで並列に処理可能
● すべての処理終了後、オプションで callback 関数を実行可
能
アカウントを並列に処理する
Script
Google Inc. - All Rights Reserved
function main() {
MccApp.accounts().executeInParallel("processAccount");
}
function processAccount() {
Logger.log("Operating on %s",
AdWordsApp.currentAccount().getCustomerId());
// アカウントへの処理を実行
// ...
return;
}
アカウントを並列に処理する
Script
Google Inc. - All Rights Reserved
function main() {
MccApp.accounts().executeInParallel("processAccount",
"allFinished");
}
function processAccount() {
...
}
function allFinished(results) {
...
}
Callback 関数を指定
Google Inc. - All Rights Reserved
● Callback 関数の results 引数を使用
● ExecutionResult オブジェクトの配列
● 1つのアカウント処理につき、1つの ExecutionResult
実行結果を分析する
Google Inc. - All Rights Reserved
● ExecutionResult オブジェクトが含む情報
● CustomerId
● Status (Success, Error, Timeout)
● Error (もしあれば)
● processAccount の返り値
実行結果を分析する
Script
Google Inc. - All Rights Reserved
function processAccount() {
return AdWordsApp.campaigns().get().totalNumEntities().toString();
}
function allFinished(results) {
var totalCampaigns = 0;
for (var i = 0; i < results.length; i++) {
totalCampaigns += parseInt(results[i].getReturnValue());
}
Logger.log("There are %s campaigns under MCC ID: %s.",
totalCampaigns,
AdWordsApp.currentAccount().getCustomerId());
}
実行結果を返す
Google Inc. - All Rights Reserved
● 処理関数は string の返り値を返すことができる
● 複雑なオブジェクトを返したい場合には、JSON.stringify /
JSON.parse を使用してオブジェクトの serialize /
deserialize を行う
● 大きな値を返したい場合には、各種データストレージを使う
(E.g. SpreadSheetApp, DriveApp...)
実行結果を返す
Google Inc. - All Rights Reserved
実行時間制限
30-X分
processAccount(A)
30分30分
30-X分
processAccount(C)
30-X分
processAccount(B)
main() 関数
executeInParallel() をアカウント
A, B, C へ実行
allFinished()
Xminutes
1時間
Google Inc. - All Rights Reserved
参考資料
MccApp Documentation: http://goo.gl/r0pGJO
Feature guide: http://goo.gl/u65RAF
Code snippets: http://goo.gl/2BXrfo
Complete solutions: http://goo.gl/JSjYyf
Forum: http://goo.gl/sc95Q8
Google Inc. - All Rights Reserved
Questions?
Google Inc. - All Rights Reserved

More Related Content

PDF
Getting started with Google Analytics and the AdWords API
PDF
Bid Estimation with the AdWords API (v2)
PDF
Opportunity Analysis with Kratu (v2)
PDF
AdWords API Feed Services
PDF
GoogleWebsiteOptimizerの使い方:非同期タグバージョン
PPT
GWOの使い方~非同期タグVer~
PPTX
Azure Machine Learning Services 概要 - 2019年2月版
PDF
Windows ストア lob アプリ開発のためのガイダンスとフレームワークのご紹介 rev
Getting started with Google Analytics and the AdWords API
Bid Estimation with the AdWords API (v2)
Opportunity Analysis with Kratu (v2)
AdWords API Feed Services
GoogleWebsiteOptimizerの使い方:非同期タグバージョン
GWOの使い方~非同期タグVer~
Azure Machine Learning Services 概要 - 2019年2月版
Windows ストア lob アプリ開発のためのガイダンスとフレームワークのご紹介 rev

Similar to Mcc scripts deck (日本語) (10)

PPTX
Vertica 9.0.0 新機能
PDF
HTML5で作るハイブリッドアプリに広告実装ハンズオンセミナー第2回
PDF
HTML5で作るハイブリッドアプリに広告実装ハンズオンセミナー
PPTX
Team Foundation Server / Visual Studio Team Services によるプロジェクト管理・リポジトリ管理・継続的イ...
PDF
Try_to_writecode_practicaltest #atest_hack
PPT
【17-C-2】 クラウド上でのエンタープライズアプリケーション開発
PDF
20150207コデアルエンジニア学生向けハッカソン就活イベント発表資料
PPTX
Team Foundation Server / Visual Studio Team Services 手順書
PPTX
Angular jsとsinatraでturbolinks
PDF
LabVIEW NXG Web Module Training Slide
Vertica 9.0.0 新機能
HTML5で作るハイブリッドアプリに広告実装ハンズオンセミナー第2回
HTML5で作るハイブリッドアプリに広告実装ハンズオンセミナー
Team Foundation Server / Visual Studio Team Services によるプロジェクト管理・リポジトリ管理・継続的イ...
Try_to_writecode_practicaltest #atest_hack
【17-C-2】 クラウド上でのエンタープライズアプリケーション開発
20150207コデアルエンジニア学生向けハッカソン就活イベント発表資料
Team Foundation Server / Visual Studio Team Services 手順書
Angular jsとsinatraでturbolinks
LabVIEW NXG Web Module Training Slide
Ad

More from marcwan (20)

PDF
Opportunity Analysis with Kratu
PDF
07. feeds update
PDF
AdWords API & OAuth 2.0, Advanced
PDF
AdWords Scripts and MCC Scripting
PDF
AwReporting Update
PDF
Getting Started with AdWords API and Google Analytics
PDF
Shopping Campaigns and AdWords API
PDF
API Updates for v201402
PDF
AdWords API Targeting Options
PDF
Reporting Tips and Tricks (Spanish)
PDF
Rate limits and performance (Spanish)
PDF
OAuth 2.0 (Spanish)
PDF
End to-end how to build a platform (Spanish)
PDF
AwReporting tool introduction (Spanish)
PDF
Api update rundown (Spanish)
PDF
AdWords Scripts (Spanish)
PDF
Mobile landing pages (Spanish)
PDF
Rate limits and performance
PDF
OAuth 2.0 refresher
PDF
Mobile landing pages
Opportunity Analysis with Kratu
07. feeds update
AdWords API & OAuth 2.0, Advanced
AdWords Scripts and MCC Scripting
AwReporting Update
Getting Started with AdWords API and Google Analytics
Shopping Campaigns and AdWords API
API Updates for v201402
AdWords API Targeting Options
Reporting Tips and Tricks (Spanish)
Rate limits and performance (Spanish)
OAuth 2.0 (Spanish)
End to-end how to build a platform (Spanish)
AwReporting tool introduction (Spanish)
Api update rundown (Spanish)
AdWords Scripts (Spanish)
Mobile landing pages (Spanish)
Rate limits and performance
OAuth 2.0 refresher
Mobile landing pages
Ad

Mcc scripts deck (日本語)

  • 1. Google Inc. - All Rights Reserved
  • 4. Google Inc. - All Rights Reserved はじめに
  • 5. Google Inc. - All Rights Reserved ● AdWords のデータをプログラムから操作する方法 ● JavaScript を使用 ● 開発環境は AdWords UI の中に用意 AdWords スクリプトの復習
  • 6. Script Google Inc. - All Rights Reserved function main() { // AWQL を使って指定した名前のキャンペーンを取得 var demoCampaign = AdWordsApp.campaigns(). withCondition("Name='Demo campaign'").get().next(); // AWQL を使って、直下の広告グループを取得 var demoAdGroup = demoCampaign.adGroups(). withCondition("Name='Demo adgroup'").get().next(); // 広告グループの設定を変更 demoAdGroup.setKeywordMaxCpc(1.2); } AdWords スクリプトの復習
  • 7. Google Inc. - All Rights Reserved ● MCC レベルで使える AdWords スクリプト ● 多くのアカウントを管理可能に MCC スクリプトとは?
  • 8. Google Inc. - All Rights Reserved ● 現在は、すべての方がご利用になれます 利用可能な方
  • 9. Google Inc. - All Rights Reserved ● 1つのスクリプトで複数のアカウントを管理可能 ● 1つのスクリプトを複数のアカウントにコピーする必要なし ● 複数のアカウントを並列に処理 利点
  • 10. Google Inc. - All Rights Reserved ● 管理している全てのアカウントの入札単価を調整 ● 複数アカウントのレポートを出力 よくある使い方
  • 11. Google Inc. - All Rights Reserved MCC スクリプトを使ってみる 1 2
  • 12. Google Inc. - All Rights Reserved 使ってみよう
  • 13. Script Google Inc. - All Rights Reserved 初めての MCC スクリプト function main() { // 全ての子アカウントを取得 var accountIterator = MccApp.accounts().get(); // 取得したアカウントを順に処理 while (accountIterator.hasNext()) { var account = accountIterator.next(); // 子アカウントのパフォーマンス データを取得 var stats = account.getStatsFor("THIS_MONTH"); // ログに出力 Logger.log("%s,%s,%s,%s", account.getCustomerId(), stats.getClicks(), stats.getImpressions(), stats.getCost()); } }
  • 14. Google Inc. - All Rights Reserved ● アカウントを管理する機能を提供 ● 子アカウントを取得 ● 操作するアカウントを選択 ● 複数のアカウントを並列に処理 MccApp クラス
  • 15. Google Inc. - All Rights Reserved var accountIterator = MccApp.accounts().get(); ● MccApp.accounts メソッドを使用 ● デフォルトでは、全ての子アカウントを返す(サブMCCは除く) 子アカウントを選択する Script
  • 16. Google Inc. - All Rights Reserved ● アカウント レベルでフィルターすることが可能 子アカウントを選択する var accountIterator = MccApp.accounts() .withCondition('LabelNames CONTAINS "xxx"') .get(); Script
  • 17. Google Inc. - All Rights Reserved ● Customer Id を直接指定することも可能 子アカウントを選択する var accountIterator = MccApp.accounts() .withIds(['123-456-7890', '345-678-9000']) .get(); Script
  • 18. Google Inc. - All Rights Reserved ● デフォルトでは、スクリプトが置かれているアカウント ● MccApp.select を使い、操作対象アカウントを変更 ● AdWordsApp クラスを使いアカウントを操作 ● 最後に操作対象をMCC アカウントへ戻すことを忘れずに! いまどのアカウントを操作している?
  • 19. Script Google Inc. - All Rights Reserved var childAccount = MccApp.accounts().withIds(["918-501-8835"]) .get().next(); // 現在のMCCアカウントを保存 var mccAccount = AdWordsApp.currentAccount(); // 子アカウントを選択 MccApp.select(childAccount); // 子アカウントへの処理を実行 ... // 操作対象を MCC アカウントに戻す MccApp.select(mccAccount); 特定の子アカウントを操作する
  • 20. Google Inc. - All Rights Reserved アカウントを並列に処理する
  • 21. Google Inc. - All Rights Reserved ● AccountSelector.executeInParallel メソッドを使 用 ● 50 アカウントまで並列に処理可能 ● すべての処理終了後、オプションで callback 関数を実行可 能 アカウントを並列に処理する
  • 22. Script Google Inc. - All Rights Reserved function main() { MccApp.accounts().executeInParallel("processAccount"); } function processAccount() { Logger.log("Operating on %s", AdWordsApp.currentAccount().getCustomerId()); // アカウントへの処理を実行 // ... return; } アカウントを並列に処理する
  • 23. Script Google Inc. - All Rights Reserved function main() { MccApp.accounts().executeInParallel("processAccount", "allFinished"); } function processAccount() { ... } function allFinished(results) { ... } Callback 関数を指定
  • 24. Google Inc. - All Rights Reserved ● Callback 関数の results 引数を使用 ● ExecutionResult オブジェクトの配列 ● 1つのアカウント処理につき、1つの ExecutionResult 実行結果を分析する
  • 25. Google Inc. - All Rights Reserved ● ExecutionResult オブジェクトが含む情報 ● CustomerId ● Status (Success, Error, Timeout) ● Error (もしあれば) ● processAccount の返り値 実行結果を分析する
  • 26. Script Google Inc. - All Rights Reserved function processAccount() { return AdWordsApp.campaigns().get().totalNumEntities().toString(); } function allFinished(results) { var totalCampaigns = 0; for (var i = 0; i < results.length; i++) { totalCampaigns += parseInt(results[i].getReturnValue()); } Logger.log("There are %s campaigns under MCC ID: %s.", totalCampaigns, AdWordsApp.currentAccount().getCustomerId()); } 実行結果を返す
  • 27. Google Inc. - All Rights Reserved ● 処理関数は string の返り値を返すことができる ● 複雑なオブジェクトを返したい場合には、JSON.stringify / JSON.parse を使用してオブジェクトの serialize / deserialize を行う ● 大きな値を返したい場合には、各種データストレージを使う (E.g. SpreadSheetApp, DriveApp...) 実行結果を返す
  • 28. Google Inc. - All Rights Reserved 実行時間制限 30-X分 processAccount(A) 30分30分 30-X分 processAccount(C) 30-X分 processAccount(B) main() 関数 executeInParallel() をアカウント A, B, C へ実行 allFinished() Xminutes 1時間
  • 29. Google Inc. - All Rights Reserved 参考資料 MccApp Documentation: http://goo.gl/r0pGJO Feature guide: http://goo.gl/u65RAF Code snippets: http://goo.gl/2BXrfo Complete solutions: http://goo.gl/JSjYyf Forum: http://goo.gl/sc95Q8
  • 30. Google Inc. - All Rights Reserved Questions?
  • 31. Google Inc. - All Rights Reserved