# 初期設定方法

## BigQuery連携の概要

WicleのBigQuery連携を設定することで、貴社BigQuery環境上で直接イベントデータ等にアクセスし自社データとの結合や既成のBI環境での可視化といったことが可能になります。

独自のデータ分析基盤上でユーザーデータを組み合わせたい場合に最適なオプションです。

## 設定フロー <a href="#setup-flow" id="setup-flow"></a>

[プラン・請求画面](https://app.wicle.io/settings/billing)からご自身で契約・設定が可能です。

### 1. BigQuery連携の契約 <a href="#subscribe" id="subscribe"></a>

1. [プラン・請求画面](https://app.wicle.io/settings/billing)を開く
2. 「オプション機能」セクションのBigQuery連携で「オプションを有効化」をクリック
3. 決済手続きを完了する

{% hint style="info" %}
BigQuery連携はメインプランに関わらず個別で契約可能です。また、決済方法の登録が必要です。
{% endhint %}

### 2. Service Accountの登録 <a href="#add-service-account" id="add-service-account"></a>

BigQuery連携の契約後、プラン・請求画面に「Service Account管理」セクションが表示されます。

1. 貴社のGCPサービスアカウント（SA）のメールアドレスを入力する
2. 「追加」をクリックする
3. 確認ダイアログで内容を確認し、追加を実行する

初回のSA登録時に、Wicle側でデータセットとビューの自動セットアップが行われます。完了後、登録したSAからBigQuery上のデータにアクセスできるようになります。

{% hint style="info" %}
Service Accountの管理は組織のOwner権限を持つアカウントのみ操作できます。
{% endhint %}

### 3. BigQueryでのデータ確認 <a href="#verify-data" id="verify-data"></a>

登録したSAの権限で、BigQueryコンソールまたはBIツールからデータセットにアクセスできることを確認してください。

アクセス先は以下の形式になります。

```
`wicle-customers.{参照するプロジェクトのAPI_KEY}.{テーブル名}`
```

具体的なテーブル構成については[テーブル定義](/bigquery-integration/table-schema.md)をご参照ください。

## Service Accountの管理 <a href="#manage-service-accounts" id="manage-service-accounts"></a>

[プラン・請求画面](https://app.wicle.io/settings/billing)の「Service Account管理」セクションから、SAの追加・削除ができます。

### SAの追加 <a href="#add-sa" id="add-sa"></a>

テスト等の用途で複数のSAを登録することも可能です。

* すでにBI用に運用しているSAに権限付与する形ですと、既存の貴社内BigQueryテーブルと結合（BIツールで1クエリでJOIN）もすぐにできるため最もスムーズです

### SAの削除 <a href="#remove-sa" id="remove-sa"></a>

登録済みのSAの右側にある削除ボタンをクリックすることで、そのSAのデータセットへのアクセス権を取り消すことができます。

## BigQuery連携の解約 <a href="#cancel" id="cancel"></a>

BigQuery連携を解約するには、先に**すべてのService Accountを削除**する必要があります。

すべてのSAを削除した後、プラン・請求画面のBigQuery連携セクションから「キャンセル」をクリックしてください。

{% hint style="warning" %}
年間契約中の場合はプラン・請求画面からの解約ができません。チャットサポートよりご連絡ください。
{% endhint %}

## 注意事項 <a href="#notes" id="notes"></a>

* データセットのリージョンは `US` リージョンとなります。
* クエリジョブは貴社プロジェクト上で実行される形式となります。テーブル毎に適切なパーティションキー指定等を行い過度なリソース消費がされない様ご注意ください。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wicle.io/bigquery-integration/setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
