# Pushcode Import Integration ![](/assets/fc6435db26e28e5d9619f4da4a190599.91b8c4c9f3220bf2f733043630ae743d437c5a957d08dee858ff5e146c24d1e8.4679117a.png) **PUSHCODE**は、個々のサイト訪問者に最も関連性の高いコンテンツを適切なタイミングで配信する、日本で人気のあるWebプッシュサービスです。 PUSHCODEのこのインポート統合により、Google Cloud StorageからPUSHCODEが提供する以下のデータをインポートできます: - Subscriber List - Segment List - Push Result ## 前提条件 - Treasure Dataの基本知識 - PUSHCODEの基本知識 - Google Cloud StorageのImport Connectorの基本知識 ## 要件と制限事項 - PUSHCODEアカウント - PUSHCODEでTreasure Data Integration設定を有効にする - Subscriber List / Segment List / Push Resultのファイルは毎日作成されます ## PUSHCODE GCS情報を取得 1. PUSHCODE Console > Account Settingsに移動します。 2. Treasure Data統合を有効にします。 ![](/assets/pushcode_td_integration_button.d35231131c481a88c9aa4ecb70cbc4139aad79d4f8ee2ba5b71489f78d4d7a25.4679117a.png) Treasure Data統合を設定すると、以下の情報が提供されます。 - 割り当てられたGoogle Cloud Storage Bucket Name - Google Cloud Storageサービスアカウントキー(JSONファイル) ![](/assets/pushcode_td_integration_settings.65f7aa6e711022d540c19f7a101ac90b4f998b5a5244fa1a0cb466e923ad95d7.4679117a.png) Treasure Data Consoleでの設定のために、これらを利用可能な状態にしておいてください。 ## TD Console経由でPUSHCODEからインポート ### 認証を作成 PUSHCODE統合はGoogle Cloud Storage統合を使用します。JSONキーファイルを使用して認証を作成するには、[Google Cloud Storage Import Integration](/ja/int/google-cloud-storage-import-integration)の手順に従ってください。 ### ソースを作成 1. TD Consoleを開きます。 2. **Integrations Hub** > **Authentications**に移動します。 3. 新しい認証を見つけて、**New Source**を選択します。 ### 接続を作成 | Parameter | Description | | --- | --- | | Data Transfer Name | 転送の名前を定義できます。 | | Authentication | 転送に使用される認証名。 | 1. Data Transfer Nameフィールドにソース名を入力します。 2. **Next**を選択します。 Create Sourceページが表示され、**Source Table**タブが選択されています。 ### ソーステーブルを識別 1. **Next**を選択します。 2. source Tableダイアログが開きます。ターゲットPUSHCODEデータに基づいて以下のパラメータを編集します。 | Import Target List | Parameter | Description | | --- | --- | --- | | Subscriber List | Bucket | Bucket NameはPUSHCODEコンソールで確認できます | | Path Prefix | *"subscriber_list/subscriber_list_"* | | | Path Regex | *"subscriber_list/subscriber_list_[0-9]{12}.csv.gz$"* | | | Start after path | 最新のファイル*'subscriber_list/subscriber_list_YYYYMMDD0000.csv.gz'*のみをインポートするには、YYYYは年、MMは月、DDは日(ゼロパディング)です。すべての過去データをインポートするには、空白のままにします。 | | | Incremental? | インクリメンタルローディングを行う場合はチェックします。 | | | Segment List | Bucket | Bucket NameはPUSHCODEコンソールで確認できます | | Path Prefix | *"segment_list/segment_list_"* | | | Path Regex | *"segment_list/segment_list_[0-9]{12}.csv.gz$"* | | | Start after path | 最新のファイル*'segment_list/segment_list_YYYYMMDD0000.csv.gz'*のみをインポートするには、YYYYは年、MMは月、DDは日(ゼロパディング)です。すべての過去データをインポートするには、空白のままにします。 | | | Incremental? | Checked | | | Push Result | Bucket | Bucket NameはPUSHCODEコンソールで確認できます | | Path Prefix | *"push_result/push_result_"* | | | Path Regex | *"push_result/push_result_[0-9]{12}.csv.gz$"* | | | Start after path | 最新のファイル*'"push_result/push_result_[0-9]{12}.csv.gz$'*のみをインポートするには、YYYYは年、MMは月、DDは日(ゼロパディング)です。すべての過去データをインポートするには、空白のままにします。 | | | Incremental? | Checked | | ### データ設定を定義 インポートされるファイル形式は以下の通りです。コネクタがこれらの形式を自動的に推測するため、データ設定を手動で定義する必要はありません。 | Import Target List | Name | Description | Type | | --- | --- | --- | --- | | Subscriber list | domain_id | 設定されたサイトID | int | | domain | 設定されたサイトドメイン | string | | | user_id | 購読したユーザーID | int | | | browser_id | 購読したブラウザID | int | | | user_agent | ブラウザのUser Agent | string | | | subscribe_time | ユーザーが購読した時刻 | string | | | status | 0: 購読済み / 1: 拒否 | int | | | unsubscribe_time | ユーザーが拒否した時刻(ユーザーが拒否していない場合、この値は追加されません) | string | | | Segment list | list_id | ユーザーリストID | int | | list_name | ユーザーリスト名 | string | | | user_id | 配信されたユーザーID | string | | | Push Result | domain_id | 設定されたサイトID | int | | domain | 設定されたサイトドメイン | string | | | push_scenario_inst_i | プッシュ通知ID | int | | | browser_id | 購読したブラウザID | int | | | user_id | 購読したユーザーID | int | | | push_create_time | PUSHCODEがプッシュ通知を登録した時刻 | string | | | push_sent_time | PUSHCODEがプッシュ通知を送信した時刻 | string | | | push_view_time | ユーザーがプッシュ通知を表示した時刻 | int | | | push_click_time | ユーザーがプッシュ通知をクリックした時刻 | string | | **Next**を選択します。 ### Data Preview You can see a [preview](/products/customer-data-platform/integration-hub/batch/import/previewing-your-source-data) of your data before running the import by selecting Generate Preview. Data preview is optional and you can safely skip to the next page of the dialog if you choose to. 1. Select **Next**. The Data Preview page opens. 2. If you want to preview your data, select **Generate Preview**. 3. Verify the data. ### Data Placement For data placement, select the target database and table where you want your data placed and indicate how often the import should run. 1. Select **Next.** Under Storage, you will create a new or select an existing database and create a new or select an existing table for where you want to place the imported data. 2. Select a **Database** > **Select an existing** or **Create New Database**. 3. Optionally, type a database name. 4. Select a **Table**> **Select an existing** or **Create New Table**. 5. Optionally, type a table name. 6. Choose the method for importing the data. - **Append** (default)-Data import results are appended to the table. If the table does not exist, it will be created. - **Always Replace**-Replaces the entire content of an existing table with the result output of the query. If the table does not exist, a new table is created. - **Replace on New Data**-Only replace the entire content of an existing table with the result output when there is new data. 7. Select the **Timestamp-based Partition Key** column. If you want to set a different partition key seed than the default key, you can specify the long or timestamp column as the partitioning time. As a default time column, it uses upload_time with the add_time filter. 8. Select the **Timezone** for your data storage. 9. Under **Schedule**, you can choose when and how often you want to run this query. #### Run once 1. Select **Off**. 2. Select **Scheduling Timezone**. 3. Select **Create & Run Now**. #### Repeat Regularly 1. Select **On**. 2. Select the **Schedule**. The UI provides these four options: *@hourly*, *@daily* and *@monthly* or custom *cron*. 3. You can also select **Delay Transfer** and add a delay of execution time. 4. Select **Scheduling Timezone**. 5. Select **Create & Run Now**. After your transfer has run, you can see the results of your transfer in **Data Workbench** > **Databases.** ## Workflow経由でPUSHCODEからインポート ワークフローのtd_load>:オペレータを使用して、PUSHCODEからデータをインポートできます。すでにSOURCEを作成している場合は実行できます。SOURCEを作成したくない場合は、YAMLファイルを使用してインポートできます。 ### ソースを使用 1. ソースを識別します。 2. 一意のIDを取得するには、ソースリストを開いて、作成したソースを検索します。 3. メニューを開き、「Copy Unique ID」を選択します。 ![](/assets/image2021-10-12_12-26-58.09d9b84b0f1f752c7c95b0bc1c2d8e8b7302e5b91c6a3cb5f01309dadf53a604.4679117a.png) 1. td_load>オペレータを使用してワークフロータスクを定義します。 ```yaml +load: td_load>: unique_id_of_your_source database: ${td.dest_db} table: ${td.dest_table} ``` 1. ワークフローを実行します。 ### Yamlファイルを使用 1. ymlファイルを識別します。ymlファイルを作成する必要がある場合は、参考のために[Google Cloud Storage Import Integration](/ja/int/google-cloud-storage-import-integration#GoogleCloudStorageImportIntegration-ImportfromGoogleCloudStorageviaCLI(Toolbelt))を確認してください。 2. td_load>オペレータを使用してワークフロータスクを定義します。 ```yaml +load: td_load>: config/daily_load.yml database: ${td.dest_db} Table: ${td.dest_table} ``` 1. ワークフローを実行します ### サンプルワークフローコード サンプルワークフローコードについては、[Treasure Boxes](https://github.com/treasure-data/treasure-boxes/tree/master/td_load/gcs)をご覧ください。 ## CLI(Toolbelt)経由でPUSHCODEからインポート コネクタを設定する前に、最新の[TD Toolbelt](https://toolbelt.treasuredata.com/)をインストールしてください。 CLIを使用したPUSHCODE統合は、Google Cloud Storage統合を使用します。JSONキーファイルを選択して認証を作成するには、[Google Cloud Storage Import Integration](/ja/int/google-cloud-storage-import-integration#GoogleCloudStorageImportIntegration-ImportfromGoogleCloudStorageviaCLI(Toolbelt))の手順に従ってください。 必要なパラメータを取得するには、Define Data Settingsを参照してください。