Skip to content
Last updated

Google Business Profile Import Integration Using The CLI

Google Business Profile(旧Google My Business)インポート統合を使用して、顧客情報をインポートできます。このコネクタを使用すると、評価やレビューを含む、すべてのロケーションの統計情報を統合できます。Google Business Profileベータ版への参加に興味がある場合は、Treasure Dataカスタマーサクセス担当者にお問い合わせください。

前提条件

'td'コマンドのインストール

Treasure Data Toolbeltをインストールします。

設定ファイル(load.yml)の作成

アカウントの場合:

in:
    type: google_business_profile
    client_id: my-client-id
    client_secret: secret
    refresh_token: token
    data_type: accounts

filters:
    type: add_time
  - from_value: {mode: upload_time}
    to_column: {name: time}

out: {mode: append}

ロケーションの場合:

in:
    type: google_business_profile
    client_id: my-client-id
    client_secret: secret
    refresh_token: token
    data_type: locations

filters:
    type: add_time
  - from_value: {mode: upload_time}
    to_column: {name: time}

out: {mode: append}

ロケーションレビューの場合:

in:
    type: google_business_profile
    client_id: my-client-id
    client_secret: secret
    refresh_token: token
    data_type: location_reviews

filters:
    type: add_time
  - from_value: {mode: upload_time}
    to_column: {name: time}

out: {mode: append}

ロケーション日次メトリクス時系列の場合:

in:
    type: google_business_profile
    client_id: my-client-id
    client_secret: secret
    refresh_token: token
    data_type: location_daily_metrics_time_series
    daily_metric: BUSINESS_IMPRESSIONS_DESKTOP_MAPS
    start_time: "2014-10-02"
    end_time: "2014-10-03"
    incremental: true

filters:
    type: add_time
  - from_value: {mode: upload_time}
    to_column: {name: time}

out: {mode: append}

ロケーション月次検索キーワードインプレッションの場合:

in:
    type: google_business_profile
    client_id: my-client-id
    client_secret: secret
    refresh_token: token
    data_type: location_monthly_search_keywords_impressions
    start_time: "2014-10-02"
    end_time: "2014-10-03"

filters:
    type: add_time
  - from_value: {mode: upload_time}
    to_column: {name: time}

out: {mode: replace}

設定キーと説明は以下の通りです:

設定キータイプ必須説明
client_idstringyesOAuth client_id。
client_secretstringyesOAuth client_secret。
refresh_tokenstringyesOAuth refresh_tokenはaccess_tokenを交換するために使用されます。
data_typestringyesインポートするデータのタイプ: location_reviewsaccountslocationslocation_daily_metrics_time_series、またはlocation_monthly_search_keywords_impressions
daily_metricstringyesサポートされている値は(location_daily_metrics_time_seriesデータタイプにのみ必要): BUSINESS_IMPRESSIONS_DESKTOP_MAPS, BUSINESS_IMPRESSIONS_DESKTOP_SEARCH, BUSINESS_IMPRESSIONS_MOBILE_MAPS, BUSINESS_IMPRESSIONS_MOBILE_SEARCH, BUSINESS_CONVERSATIONS, BUSINESS_DIRECTION_REQUESTS, CALL_CLICKS, WEBSITE_CLICKS, BUSINESS_BOOKINGS, BUSINESS_FOOD_ORDERS
start_timeintno- ロケーション日次メトリクス時系列: レポート時間範囲の開始時刻(YYYY-MM-DD形式、例: 2022-10-10、範囲は包含的)。 - ロケーション月次検索キーワードインプレッション: レポート時間範囲の開始時刻(YYYY-MM形式、例: 2022-10-10、範囲は包含的)
end_timeintno- ロケーション日次メトリクス時系列: レポート時間範囲の終了時刻(YYYY-MM-DD形式、例: 2022-10-10、範囲は包含的)。 - ロケーション月次検索キーワードインプレッション: レポート時間範囲の終了時刻(YYYY-MM形式、例: 2022-10-10、範囲は包含的)
incrementalbooleannoインポートを増分にするかどうか。
retry_limitintno各API呼び出しの最大リトライ回数。デフォルト: 7
initial_retry_waitintno最初のリトライまでの待機時間。デフォルト: 5秒
max_retry_waitintnoリトライ間の最大待機時間。デフォルト: 300秒

ロードジョブの実行

ロードジョブを送信します。データサイズによっては数時間かかる場合があります。ユーザーはデータが保存されるdatabaseとtableを指定する必要があります。

td connector:issue load.yml \
--database td_sample_db \
--table td_sample_table

上記のコマンドは、*database(td_sample_db)table(td_sample_table)*がすでに作成されていることを前提としています。TDにdatabaseまたはtableが存在しない場合、このコマンドは成功しないため、databaseとtableを手動で作成するか、~~--auto-create-tableオプションをtd connector:issue~~コマンドと共に使用して、次のようにdatabaseとtableを自動的に作成します。

$ td connector:issue load.yml --database td_sample_db --table td_sample_table --time-column created_at --auto-create-table

--time-columnオプションを使用して、Time Format列を「Partitioning Key」に割り当てることができます。

スケジュール実行

定期的なデータインポートのために、定期的なデータコネクタ実行をスケジュールできます。高可用性を確保するために、スケジューラを注意深く設定しています。この機能を使用することで、ローカルデータセンターにcronデーモンを配置する必要がなくなります。

スケジュールの作成

td connector:createコマンドを使用して新しいスケジュールを作成できます。スケジュールの名前、cron形式のスケジュール、データが保存されるdatabaseとtable、およびデータコネクタ設定ファイルが必要です。

td connector:create \
daily_report_import \
"10 0 * * *" \
td_sample_db \
td_sample_table \
load.yml

cronパラメータは、@hourly@daily@monthlyの3つの特別なオプションも受け入れます。

スケジュールのリスト表示

td connector:listでスケジュールエントリのリストを確認できます。

td connector:list

スケジュールの設定と履歴の表示

td connector:showは、スケジュールエントリの実行設定を表示します。

$ td connector:show daily_report_import
Name     :daily_report_import
Cron     : 10 0 * * *
Timezone : UTC
Delay    : 0
Database : td_sample_db
Table    : td_sample_table
Config
---
// 表示されるload.yml設定。

~~td connector:historyは、スケジュールエントリの実行履歴を表示します。個々の実行結果を調査するには、td job jobid~~を使用します。

スケジュールの削除

td connector:deleteは、スケジュールを削除します。

$ td connector:delete daily_report_import