Shopify データを BigQuery に読み込む

Shopify から BigQuery にデータを読み込むには、Shopify 用の BigQuery Data Transfer Service コネクタを使用します。BigQuery Data Transfer Service を使用すると、Shopify から BigQuery に最新のデータを追加する定期的な転送ジョブをスケジュール設定できます。

Shopify コネクタは、次のリソースから Collections や Orders などの GraphQL ベースのリソースのデータ転送をサポートしています。

  • サブスクリプション ベースのアカウント
  • パートナー アカウント

制限事項

Shopify のデータ移転には、次の制限があります。

  • データ転送に GiftCards オブジェクトを含めるには、このデータ転送に関連付けられているアカウントに ShopifyPlus サブスクリプションが必要です。
  • 次のアプリ サブスクリプション データ オブジェクトをデータ転送に含めるには、Shopify ストアにインストールされているアプリが販売チャネルアプリである必要があります。
    • AppSubscriptionLineItems
    • AppSubscriptions
    • ProductResourceFeedbacks
  • 割引機能を必要とする次の Shopify データ オブジェクトを含めるには、Shopify CLI を使用して Shopify アプリを作成する必要があります。
    • DiscountsCodeApp
    • DiscountsCodeBasic

始める前に

以降のセクションでは、Shopify のデータ転送を作成する前に必要な前提条件について説明します。

Shopify の前提条件

  • Shopify アカウントと Shopify ストアが必要です。
  • Shopify ストア用のカスタム Shopify アプリが必要です。詳細については、カスタムアプリをご覧ください。
  • BigQuery に転送する Shopify データ オブジェクトに必要なスコープへのアクセス権が必要です。各オブジェクトに必要なスコープの一覧については、サポートされているオブジェクトと必要なスコープをご覧ください。

BigQuery の前提条件

必要な BigQuery のロール

BigQuery Data Transfer Service データ転送の作成に必要な権限を取得するには、プロジェクトに対する BigQuery 管理者 (roles/bigquery.admin)IAM ロールを付与するよう管理者に依頼します。ロールの付与については、プロジェクト、フォルダ、組織に対するアクセス権の管理をご覧ください。

この事前定義ロールには、BigQuery Data Transfer Service のデータ転送の作成に必要な権限が含まれています。必要とされる正確な権限については、「必要な権限」セクションを開いてご確認ください。

必要な権限

BigQuery Data Transfer Service のデータ転送を作成するには、次の権限が必要です。

  • BigQuery Data Transfer Service の権限
    • bigquery.transfers.update
    • bigquery.transfers.get
  • BigQuery の権限
    • bigquery.datasets.get
    • bigquery.datasets.getIamPolicy
    • bigquery.datasets.update
    • bigquery.datasets.setIamPolicy
    • bigquery.jobs.create

カスタムロールや他の事前定義ロールを使用して、これらの権限を取得することもできます。

詳細については、bigquery.admin へのアクセス権を付与するをご覧ください。

Pub/Sub の転送実行通知を設定する場合は、Identity and Access Management(IAM)権限の pubsub.topics.setIamPolicy が付与されていることを確認します。メール通知のみを設定する場合は、Pub/Sub の権限は必要ありません。詳細については、BigQuery Data Transfer Service の実行通知をご覧ください。

Shopify のデータ転送を設定する

次のいずれかのオプションを使用して転送構成を設定し、Shopify データを BigQuery に追加します。

コンソール

  1. Google Cloud コンソールの [データ転送] ページに移動します。

    [データ転送] に移動

  2. [転送を作成] をクリックします。

  3. [ソースタイプ] セクションの [ソース] で、[Shopify] を選択します。

  4. [データソースの詳細] セクションで、次のようにします。

    • [Shop name] に Shopify ショップの名前を入力します。たとえば、販売アカウント ID が storename.myshopify.com の場合、ショップ名は storename です。
    • [クライアント ID] と [クライアント シークレット] に、Shopify アプリのクライアント ID とシークレットを入力します。詳細については、クライアント シークレットについてをご覧ください。
    • [転送する Shopify オブジェクト] で、[参照] をクリックします。
      • BigQuery 宛先データセットに転送するオブジェクトを選択します。このフィールドには、データ転送に含めるオブジェクトを手動で入力することもできます。
  5. [転送先の設定] セクションの [データセット] で、データを保存するために作成したデータセットを選択します。

  6. [転送構成名] セクションの [表示名] に、データ転送の名前を入力します。

  7. [スケジュール オプション] セクションで:

    • [繰り返しの頻度] リストで、この転送の実行頻度を指定するオプションを選択します。カスタムの繰り返しの頻度を指定するには、[カスタム] を選択します。[オンデマンド] を選択した場合、手動で転送をトリガーすると、この転送が実行されます。
    • 必要に応じて、[すぐに開始] を選択するか、[設定した時刻に開始] を選択して開始日と実行時間を指定します。
  8. 省略可: [通知オプション] セクションで、次のようにします。

    • メール通知を有効にするには、[メール通知] をクリックします。このオプションを有効にした場合、転送の実行が失敗すると転送管理者にメール通知が送信されます。
    • この転送の Pub/Sub 転送実行通知を有効にするには、[Pub/Sub 通知] をクリックします。トピック名を選択するか、[トピックを作成] をクリックしてトピックを作成します。
  9. [保存] をクリックします。

bq

bq mk コマンドを入力して、転送作成フラグ --transfer_config を指定します。

bq mk
    --transfer_config
    --project_id=PROJECT_ID
    --data_source=DATA_SOURCE
    --display_name=NAME
    --target_dataset=DATASET
    --params='PARAMETERS'

各パラメータの説明は次のとおりです。

  • PROJECT_ID(省略可): Google Cloud プロジェクト ID。--project_id で特定のプロジェクトを指定しない場合は、デフォルトのプロジェクトが使用されます。
  • DATA_SOURCE: データソース - shopify。
  • NAME: データ転送構成の表示名。転送名には、後で修正が必要になった場合に識別できる任意の名前を使用できます。
  • DATASET: 転送構成のターゲット データセット。
  • PARAMETERS: 作成される転送構成のパラメータを JSON 形式で指定します。例: --params='{"param":"param_value"}'。Shopify データ転送のパラメータは次のとおりです。

    • assets: BigQuery に転送する Shopify オブジェクトのパス。
    • connector.shopName: Shopify ショップの名前。たとえば、販売アカウント ID が storename.myshopify.com の場合、ショップ名は storename です。
    • connector.authentication.accessToken: Shopify Admin API アクセス トークン。

次のコマンドは、デフォルト プロジェクトに Shopify の増分データ転送を作成します。

bq mk
    --transfer_config
    --target_dataset=mydataset
    --data_source=shopify
    --display_name='My Transfer'
    --params='{"assets": ["Orders"]
        "connector.shopName": "storename",
        "connector.authentication.accessToken":"sk_test_123456789"}'
転送構成を保存すると、Shopify コネクタはスケジュール オプションに従って転送実行を自動的にトリガーします。転送を実行するたびに、Shopify コネクタは Shopify から BigQuery に使用可能なすべてのデータを転送します。

定期的なスケジュール外でデータ転送を手動で実行するには、バックフィル実行を開始します。

サポートされているオブジェクトと必要なスコープ

次の表に、BigQuery に転送できる Shopify データ オブジェクトと、各オブジェクトに必要なスコープを示します。

データ オブジェクト 必要なスコープ
AppFeedbacks スコープは不要
AppSubscriptionLineItems スコープは不要
AppSubscriptions スコープは不要
カタログ read_products または read_product_listings
read_publications
コレクション read_products
read_publications
会社 read_customers または read_companies
CompanyContactRoleAssignments read_customers または read_companies
CompanyContacts read_customers または read_companies
CompanyLocations read_customers または read_companies
お客様 read_customers
write_customers
read_customer_merge
read_locations または read_inventory
read_markets
read_orders
DeliveryProfiles read_products
read_shipping
DiscountsAutomaticApp read_discounts
DiscountsAutomaticBasic read_discounts
DiscountsAutomaticBxgy read_discounts
DiscountsCodeApp read_discounts
DiscountsCodeBasic read_discounts
DiscountsCodeBxgy read_discounts
DraftOrders read_customers
read_draft_orders
read_orders
read_payment_terms
ファイル read_files
FulfillmentEvents read_orders
FulfillmentOrders read_locations
read_orders
read_assigned_fulfillment_orders、read_merchant_managed_fulfillment_orders、read_third_party_fulfillment_orders
フルフィルメント read_fulfillments または read_products
read_locations
read_orders
FulfillmentServices read_locations または read_inventory
read_fulfillments、read_products、read_custom_fulfillment_services、または assigned_fulfillment_orders
FulfillmentTrackingInfo read_fulfillments または read_products
read_locations
read_orders
GiftCards read_gift_cards
read_orders
read_customers
InventoryItems read_inventory
read_products
ロケーション read_locations
read_fulfillments
Metafields_Article read_content
Metafields_Blog read_content
Metafields_Collection read_products
read_publications
Metafields_Customer read_customers
write_customers
read_customer_merge
read_locations または read_inventory
read_markets
read_orders
Metafields_Draft_Order read_customers
read_draft_orders
read_orders
read_payment_terms
Metafields_Order read_customers
read_inventory
read_locations
read_orders
read_payment_terms
Metafields_Page read_content
Metafields_Product read_products
read_product_listings
read_publications
Metafields_Selling_Plan read_products
Metafields_Shop スコープは不要
Metafields_Variant read_products
read_shipping
OrderLineItems read_orders
read_products
OrderRiskAssessments read_orders
注文 read_customers
read_inventory
read_locations
read_orders
read_payment_terms
read_draft_orders
read_products または read_fulfillments
OrderTransactions read_orders
read_products
PriceLists read_products
ProductMediaImages read_products
ProductOptions read_products
ProductOptionValues read_products
ProductResourceFeedbacks read_resource_feedbacks
read_products
プロダクト read_products
read_product_listings
read_publications
ProductVariants read_products
read_shipping
パブリケーション read_products
read_publications
払い戻し read_products
read_orders
read_returns
戻り値 read_orders
read_returns
ScriptTags read_script_tags
セグメント read_customers
SellingPlanGroups read_products
StorefrontAccessTokens スコープは不要
UrlRedirects read_online_store_navigation

データ型マッピング

次の表に、Shopify のデータ型と対応する BigQuery データ型を示します。

Shopify のデータ型 BigQuery のデータ型
String STRING
Int INT64
Decimal NUMERIC
Double FLOAT64
Long BIGNUMERIC
Bool BOOL
Datetime TIMESTAMP

料金

この機能のプレビュー版では、Shopify データを BigQuery に転送しても費用はかかりません。

転送の設定に関するトラブルシューティング

データ転送の設定で問題が発生した場合は、Shopify の転送に関する問題をご覧ください。

次のステップ

  • BigQuery Data Transfer Service の概要については、BigQuery Data Transfer Service とはをご覧ください。
  • 転送構成に関する情報の取得、転送構成の一覧表示、転送の実行履歴の表示など、転送の使用方法については、転送の管理をご覧ください。