アナリティクス4(GA4)でディレクトリ別にデータを確認したい。どうすればよいだろうか?ユニバーサルアナリティクスでは行動メニューからディレクトリ別データを確認できたはずだが。
データポータルを使えば簡単だ。
データポータルって何?という方、基本的な使い方はデータワカルで解説している。参考にしてほしい。
まずは、データポータルの作成→データソースからGA4を選択して連携しておく。
![データソース](https://asiastars.org/wp-content/uploads/2021/04/data_source.gif)
![アナリティクス](https://asiastars.org/wp-content/uploads/2021/04/ana.gif)
![GA4](https://asiastars.org/wp-content/uploads/2021/04/ana2.gif)
GA4とデータポータルを連携したら、データポータルの「フィールドを追加」からフィールドとしてデレクトリを追加してあげればよい。
![](https://asiastars.org/wp-content/uploads/2021/04/field.gif)
page_location(URL)からディレクトリを指定。
/shop/ と/countact/ という2つのディレクトリを例にしている。
フィールド名をdirectory とした。
![ディレクトリ設定](https://asiastars.org/wp-content/uploads/2021/04/directory.gif)
page_location はアナリティクス4ならでは。
CASE
WHEN REGEXP_MATCH(page_location,'.*com/shop/.*') THEN '/shop/'
WHEN REGEXP_MATCH(page_location,'.*com/contact/.*') THEN '/contact/'
END
データポータルの設定
![GA4設定](https://asiastars.org/wp-content/uploads/2021/04/ga4_setting.gif)
GA4ではイベントでPVやらクリックやらスクロール90%やらが計測される。なのでフィルタ設定も必要。「フィルターを追加」から。ここはPVで。
![](https://asiastars.org/wp-content/uploads/2021/04/add_filter.gif)
![フィルタでイベントをPVで指定。](https://asiastars.org/wp-content/uploads/2021/04/pv.gif)
![PV](https://asiastars.org/wp-content/uploads/2021/04/filter.gif)
各ページのPVをpage_location とdirectoryで表示させた。
![ページロケーションとディレクトリ](https://asiastars.org/wp-content/uploads/2021/04/directory_2.gif)
以上である。