{"id":22009961,"url":"https://github.com/terashim/dataform-google-analytics-4-example","last_synced_at":"2025-10-08T08:49:12.087Z","repository":{"id":170228509,"uuid":"326375832","full_name":"terashim/dataform-google-analytics-4-example","owner":"terashim","description":"Dataform による Google アナリティクス 4 エクスポートデータの変換パイプライン","archived":false,"fork":false,"pushed_at":"2021-08-01T06:30:39.000Z","size":15,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-09T12:39:51.857Z","etag":null,"topics":["bigquery","dataform","google-analytics"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/terashim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-03T10:01:59.000Z","updated_at":"2025-07-08T11:55:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"e42c8296-592c-4d56-8e29-f26f3a478a25","html_url":"https://github.com/terashim/dataform-google-analytics-4-example","commit_stats":null,"previous_names":["terashim/dataform-google-analytics-4-example"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/terashim/dataform-google-analytics-4-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terashim%2Fdataform-google-analytics-4-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terashim%2Fdataform-google-analytics-4-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terashim%2Fdataform-google-analytics-4-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terashim%2Fdataform-google-analytics-4-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/terashim","download_url":"https://codeload.github.com/terashim/dataform-google-analytics-4-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terashim%2Fdataform-google-analytics-4-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278916440,"owners_count":26068090,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bigquery","dataform","google-analytics"],"created_at":"2024-11-30T02:11:35.013Z","updated_at":"2025-10-08T08:49:12.051Z","avatar_url":"https://github.com/terashim.png","language":"JavaScript","readme":"Dataform による Google アナリティクス 4 エクスポートデータの変換パイプライン\n======================================================================\n\n[Google アナリティクス 4 プロパティの BigQuery Export](https://support.google.com/analytics/answer/9358801?hl=ja) をデータソースとするデータ変換パイプラインの [Dataform](https://dataform.co/) サンプルプロジェクト\n\n## 構成\n\n### Dataform データセットの分類と規約\n\nこのプロジェクトではパイプラインを大きく以下の４段階に分ける。この段階に応じて Dataform データセット定義ファイルのフォルダ分け、およびテーブル接頭辞を定める。\n\n1. **データソース**\n    - フォルダ: [`definitions/source`](./definitions/source)\n    - パイプラインの起点となるローデータを格納する。\n2. **中間データ**\n    - フォルダ: [`definitions/stage`](./definitions/stage)\n    - 加工・整形途中のデータを格納する。\n    - 基本的にパイプライン内部でのみ使用することとし、分析用途には使用しない。\n    - テーブル接頭辞 `stg__` を付ける。\n3. **データウェアハウス**\n    - フォルダ: [`definitions/warehouse`](./definitions/warehouse)\n    - 加工・整形済みデータを格納する。データマートに比べて粒度が細かく大規模なデータを持つ。\n    - アドホック分析におけるクエリ対象となる。また、データマートの上流テーブルとして再加工される。\n    - テーブル接頭辞 `dwh__` を付ける。\n4. **データマート**\n    - フォルダ: [`definitions/mart`](./definitions/mart)\n    - 集約・軽量化されたデータを格納する。データウェアハウスに比べて粒度が粗く小規模なデータを持つ。\n    - 目的に応じて作成される。\n    - テーブル接頭辞 `dm__` を付ける。\n\n### Google アナリティクス 4 データパイプラインの概要\n\nこのプロジェクトでは [Google アナリティクス 4 プロパティの BigQuery Export](https://support.google.com/analytics/answer/9358801?hl=ja) の出力テーブルをデータソースとし、そこからページビューイベントを抽出・加工したデータセット [`dwh__google_analytics_pageview_events`](./definitions/warehouse/dwh__google_analytics_pageview_events.sqlx) と、さらにそれを集約した日次レポート [`dm__google_analytics_daily_traffic`](./definitions/mart/dm__google_analytics_daily_traffic.sqlx) を作成する。\n\n定義されるデータセットは以下の４つ。各データセットの詳細についてはそれぞれの SQLX ファイル内のドキュメントを参照のこと。\n\n- データソース: [`events_*`](./definitions/source/events_wildcard.sqlx)\n- 中間データ: [`stg__google_analytics_events`](./definitions/stage/stg__google_analytics_events.sqlx)\n- ページビューイベント: [`dwh__google_analytics_pageview_eventsdwh__google_analytics_pageview_events`](./definitions/warehouse/dwh__google_analytics_pageview_events.sqlx)\n- 日次トラフィックレポート: [`dm__google_analytics_daily_traffic`](./definitions/mart/dm__google_analytics_daily_traffic.sqlx)\n\nこのサンプルプロジェクトではウェブサイトのトラフィックデータ分析を想定しているため、ページビューイベントを抽出したデータセットを定義している。その他の分析（Eコマースやモバイルアプリの分析など）を行いたい場合はそれに適したデータセットを作成する。\n\n### 設定項目\n\nこのリポジトリを fork して以下の値を変更すれば、異なる Google アナリティクス 4 プロパティや異なる BigQuery プロジェクトに対して同じパイプラインを構築できる。\n\n- Google アナリティクス 4 プロパティ ID: `includes/constants.js` の `GA4_PROPERTY_ID` で指定\n- Google アナリティクス 4 のエクスポート先 BigQuery プロジェクト ID: `includes/constants.js` の `GA4_EXPORT_PROJECT_ID` で指定\n- パイプラインのデプロイ先 BigQuery プロジェクト ID: `dataform.json` の `defaultDatabase` で設定、または `environments.json` で上書き\n- パイプラインのデプロイ先 BigQuery データセット ID: `dataform.json` の `defaultSchema` で設定、または `environments.json` で上書き\n\n## 参考\n\n- [Google アナリティクス 4 プロパティの BigQuery Export - アナリティクス ヘルプ](https://support.google.com/analytics/answer/9358801?hl=ja)\n- [Dataform | Manage data pipelines in BigQuery](https://dataform.co/)\n- Dataform ドキュメント 和訳: [GitHub terashim/dataform-docs-ja](https://github.com/terashim/dataform-docs-ja)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterashim%2Fdataform-google-analytics-4-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fterashim%2Fdataform-google-analytics-4-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterashim%2Fdataform-google-analytics-4-example/lists"}