GA4 × ChatGPT 爆速!GA4 設定 & 解析 革命 第1回

BigQuery

and,a株式会社 デジタルマーケティングエンジニア 佐藤洋太

こんにちは!昨今巷で話題沸騰中のOpenAIが提供するChatGPTを実際に触って色々と試してみたので所感などをまとめようと思います。

ChatGPTとは?

ざっくりとした説明ですが、高機能なチャット型AIで、普段私たちが使う言葉で問いかけることによって回答や画像、はたまたコードまで返してくれる高度なAIです。

実際に使ってみましたがまるで人間のような受け答えです。ちなみに日本語も使えます。

サイト:https://openai.com/blog/chatgpt/

GA4で使えるか

ネットの情報や記事を見ると様々な情報が出ており、Excelで関数を組むなどの例がありました。

しかし、GA4 QuickではGoogle Analaytics + Chat GPTの切り口からいくつかの角度でアプローチをしたいと思います!

ChatGPT vs Google Tag Manager(GTM)

早速質問してみましょう!!

質問:
GoogleTagManagerでGoogle Analyticsの計測を行うにはどうすればいいですか

回答:

Google Tag Manager (GTM)を使用すると、Google Analytics(GA)の計測を簡単に行うことができます。以下のステップに従ってください:

  1. GTMアカウントを作成またはログインする
  2. 新しいタグを作成し、Google Analyticsのタグタイプを選択する
  3. GAアカウントからトラッキングIDをコピーし、GTMタグに貼り付ける
  4. GTMタグをサイトに埋め込む(GTMコードをサイトのHEADタグ内に貼り付ける)
  5. GTMを使用してタグを管理し、GAのトラッキング設定を行います。
  6. これで、GAでサイトのトラフィックやユーザー行動などを追跡することができます。
ChatGPT

お?Googleの公式の資料のような回答ですね。。。具体性をあげてみましょう。

質問:
ユーザーが電話ボタンをクリックした際にGoogleAnalyticsのイベントの計測をGoogleTagManagerで行うにはどうすればいいですか?

回答:

Google Tag ManagerでGoogle Analyticsのイベントの計測を行うには、次の手順を行います:

  1. Google Tag Managerを使用するアカウントを作成します。
  2. Google AnalyticsアカウントとGoogle Tag Managerアカウントをリンクします。
  3. Google Tag Managerにトラッキングタグを作成します。
  4. トラッキングタグにイベント計測の設定を追加します。
  5. 電話ボタンをクリックした際にGoogle Tag Managerのタグが実行されるようにJavaScriptコードを追加します。
  6. 詳細な手順については、Google Tag Managerのドキュメンテーションを参照してください。
ChatGPT

おおおおお!!!大体あってる!!AIに手順を説明してもらえる事に感動!

具体性をあげて質問するのが鍵のようですね!

質問:
GoogleAnalayticsのG-NMGXZVVKQWのアカウントでスクロール率を計測したいです。Google Tag Managerでの実装方法を教えてください。

回答:

Google AnalyticsのトラッキングコードをGoogle Tag Managerに実装することで、スクロール率の計測が可能です。以下の手順をご参照ください。

  1. Google Tag Managerアカウントにログインします。
  2. タグを作成します。「新規タグ」を選択し、「Google Analytics」タグタイプを選択します。
  3. トラッキングID「G-NMGXZVVKQW」を入力します。
  4. トラッキングオプションの「スクロール率」を有効にします。
  5. 「トリガー」を作成します。「新規トリガー」を選択し、「ページビュー」イベントを選択します。
  6. 「保存」と「パブリッシュ」を行います。

これで、Google Analyticsアカウント「G-NMGXZVVKQW」でスクロール率が計測されるようになります。

ChatGPT

素晴らしい!!細かい設定値は抜けてますが十分にわかる説明です。

これは新人さんの教育に大活躍しそうですね!!

ChatGPT vs BigQuery SQL

先ほどはデータを取得する側の質問でしたが、今度はGAに溜まったデータを取得する方法を尋ねてみます。

質問:
FirebaseのデータをBigQueryで取得したい。過去1ヶ月間のセッションを日本時間の日付毎に数えたい。

※調べたところ本記事執筆時点でChatGPTがGA4をサポートしていないため、スキーマが同じであるFirebaseとして聞いています。

回答:

FirebaseからBigQueryにデータをエクスポートすることができます。以下の手順に従って、Firebase AnalyticsデータをBigQueryにエクスポートしてください。

  1. Firebaseプロジェクト内で、BigQueryを有効にする。
  2. Firebaseアナリティクスを有効にする。
  3. BigQueryを使ってFirebase Analyticsデータをエクスポートするためのリンクを作成する。
  4. 以下のクエリを実行して、過去1ヶ月間のセッション数を日本時間の日付毎に数えます。
ChatGPT
SELECT 
  DATE(TIMESTAMP_SECONDS(event_timestamp)) AS date, 
  COUNT(DISTINCT user_pseudo_id) AS sessions 
FROM 
  `firebase_project.analytics_database.events_*` 
WHERE 
  _TABLE_SUFFIX BETWEEN FORMAT_DATE('%Y%m%d',DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)) 
  AND 
  FORMAT_DATE('%Y%m%d',CURRENT_DATE()) 
GROUP BY 
  date 
ORDER BY 
  date 
ASC

このクエリは、過去1ヶ月間のイベントデータから日付毎のセッション数を集計します。日本時間に変換するために、TIMESTAMP_SECONDS関数とDATE関数を使用しています。

ChatGPT

コードも返してくれる!!!素晴らしい!!

コードをそのまま送って解説お願いしましょう。

質問:(コードそのまま送る)

回答:

このクエリはFirebase Analyticsデータから過去1ヶ月間の日付毎のセッション数を集計するものです。

ga4-quick.analytics_302974976.events_*:Firebase Analyticsのイベントデータテーブルです。

TIMESTAMP_SECONDS(event_timestamp):イベントのタイムスタンプを秒単位の数値から日付と時間の形式に変換します。

DATE(TIMESTAMP_SECONDS(event_timestamp)):イベントの日付を抽出します。

COUNT(DISTINCT user_pseudo_id):ユーザー固有のID(user_pseudo_id)を使用して、各日付におけるセッション数をカウントします。

_TABLE_SUFFIX BETWEEN FORMAT_DATE(‘%Y%m%d’,DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)) AND FORMAT_DATE(‘%Y%m%d’,CURRENT_DATE()):データテーブルのサフィックス(日付)を使用して、過去1ヶ月間のデータのみを選択します。

GROUP BY date:日付毎にグループ化します。

ORDER BY date ASC:日付順に並び替えます。

このクエリを実行することで、過去1ヶ月間の日付毎のセッション数が得られます。

ChatGPT

おおー!!素晴らしい。

実際にBigQueryで試したところ、下記のようなエラーが出てしまったので聞いてみます。

timestamp overflow: TIMESTAMP_SECONDS(1674431996556852)

質問:

SELECT 
  DATE(TIMESTAMP_SECONDS(event_timestamp)) AS date, 
  COUNT(DISTINCT user_pseudo_id) AS sessions 
FROM 
  `ga4-quick.analytics_302974976.events_*` 
WHERE 
  _TABLE_SUFFIX BETWEEN FORMAT_DATE('%Y%m%d',DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)) 
  AND 
  FORMAT_DATE('%Y%m%d',CURRENT_DATE()) 
GROUP BY 
  date 
ORDER BY 
  date 
ASC

このコードを実行したらtimestamp overflow: TIMESTAMP_SECONDS(1674431996556852)というエラーが出ました。

回答:

このエラーは、TIMESTAMP_SECONDS関数がサポートされていないか、入力されたタイムスタンプ値が関数のサポート範囲外であることを示しています。BigQueryでは、1970年1月1日(UTC)から2038年1月19日(UTC)までの日時のみをサポートしています。

解決方法としては、タイムスタンプ値がサポート範囲内にあることを確認するか、正確なタイムスタンプ値を使用するか、タイムスタンプ値を正確な形式に変換することが考えられます。また、Firebase Analyticsのタイムスタンプを使用する場合は、サポートされているタイムスタンプ形式を確認して適切な変換を行う必要があります。

ChatGPT

実は正解はTIMESTAMP_MICROSを使います。エラーの内容と解決策まで提示できるのは素晴らしいですね。N行目のここをこう直してくださいって返事きたら凄いですね。

コード実行結果:

無事に取得できましたが、

  • 厳密なセッション数ではない
  • 日本時間にはなっていない

この点が残念でした。

まとめ

1)質問の粒度を上げればかなりの精度で回答がもらえますが、内容の正確性に欠ける為、ファクトチェックは必須。

2)今回の例ではいくつかの箇所が抜けていたのが残念でしたが、別の言い回しや再度質問をすれば恐らくは取得できそう。SQLを書くのが苦手な方は充分に使えると思います。

ChatGPTのこれからに期待大ですね!

AI+人間のエンジニアによる、GA4解析設定、などのご相談は、このBlogの運営元、and,a株式会社(https://and-aaa.com/)までお願いいたします。

関連記事

特集記事

コメント

  1. Good article. I agsolutely love thos site.
    Continue thee good work!

  2. Do yyou hawve a spam problem on thks site; I also aam a blogger, and I was wonderin your situation; many oof uus
    have crreated soome nijce procedures and wee arre looking to exchange technique with other folks, please shoot mme aan e-mail
    if interested.

  3. This iis my firdt time ppay a uick visit att here
    and i am actuwlly pleassant too read all at one place.

  4. I was able tto fimd good information from your blog posts.

  5. Verry nice post. I juhst stumbgled upon your wwblog and wanted to
    say hat I havee really enjoyed surfing around your blog
    posts. In any casee I’ll be subscrribing tto your rsss feed andd I hope yyou writte again soon!

  6. Hey there fantastic blog! Does running a blpog similzr tto tbis
    requuire a massive ammount work? I’ve virtually nno understanding off coding but I
    had een hoping to stwrt my own blo iin the near future.

    Anyway, iff you have any suggestiions or tps for new
    blog owners pleade share. I understyand this is off topic nevertheless I
    just had to ask. Kudos!

  7. Major thankies for the blog post.

  8. Looking forward to reading more. Great article post.Really thank you! Keep writing.

  9. Im obliged for the article.Much thanks again. Much obliged.

  10. I truly appreciate this post. Much obliged.

  11. Thanks again for the post.Thanks Again. Cool.

  12. I truly appreciate this article.Really looking forward to read more. Much obliged.

  13. I really liked your blog article.Thanks Again. Will read on…

  14. Wow, great post.Really looking forward to read more. Really Cool.

  15. Say, you got a nice blog post.Really looking forward to read more. Really Great.

  16. Thanks for the blog article. Really Great.

  17. Im obliged for the blog post.Much thanks again. Really Cool.

  18. I really enjoy the blog post.Thanks Again.

  19. Major thanks for the article post.Really looking forward to read more. Great.

  20. you’ve an ideal weblog right here! would you like to make some invite posts on my weblog?

  21. Thanks for the recommendations on credit repair on this excellent blog. Things i would advice people is to give up the actual mentality that they can buy now and pay out later. As being a society all of us tend to do this for many issues. This includes vacations, furniture, and items we want. However, it is advisable to separate your current wants from the needs. While you are working to improve your credit score actually you need some sacrifices. For example you are able to shop online to economize or you can turn to second hand merchants instead of high priced department stores for clothing.

  22. Howdy would you mind sharing which blog platform you’re using? I’m planning to start my own blog in the near future but I’m having a difficult time deciding between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then most blogs and I’m looking for something unique. P.S My apologies for getting off-topic but I had to ask!

  23. Today, I went to the beach front with my children. I found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She put the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear. She never wants to go back! LoL I know this is totally off topic but I had to tell someone!

  24. Im grateful for the blog post.Really thank you!

  25. Today, I went to the beachfront with my children. I found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She placed the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear. She never wants to go back! LoL I know this is completely off topic but I had to tell someone!

  26. Muchos Gracias for your article.Much thanks again. Really Cool.

  27. Hello! This is my first visit to your blog! We are a collection of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done a outstanding job!

  28. A big thank you for your blog article.Really thank you! Cool.

  29. Hmm is anyone else encountering problems with the images on this blog loading? I’m trying to figure out if its a problem on my end or if it’s the blog. Any suggestions would be greatly appreciated.

  30. Please leet mee know if you’re looking ffor a article author foor yyour
    weblog. You have some really geat articles and I believge I would bbe a
    good asset.If you evr want tto taoe soime off the lokad off,
    I’d love to write somee contejt foor yor blog in exchane ffor a lik back to
    mine. Pleasde shoot mee ann emaail iff interested. Many thanks!

  31. When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get several emails with the same comment. Is there any way you can remove people from that service? Cheers!

  32. What i don’t realize is in reality how you are no longer actually a lot more well-liked than you might be now. You are so intelligent. You realize therefore considerably relating to this topic, made me in my view believe it from so many various angles. Its like women and men don’t seem to be fascinated until it is something to accomplish with Woman gaga! Your individual stuffs nice. Always handle it up!

  33. Goood article. I aam experiencing a ffew off these issies aas well..

  34. hey there and thanks to your info ? I have definitely picked up something new from right here. I did however experience some technical points the use of this site, since I skilled to reload the web site many instances prior to I may get it to load properly. I had been puzzling over if your web hosting is OK? Now not that I am complaining, but sluggish loading cases occasions will very frequently have an effect on your placement in google and can damage your quality rating if ads and ***********|advertising|advertising|advertising and *********** with Adwords. Anyway I am adding this RSS to my e-mail and could look out for a lot extra of your respective intriguing content. Ensure that you update this once more soon..

  35. I cannot thank you enough for the blog.Really looking forward to read more. Cool.

  36. This article is absolutely incredible! The author has done a phenomenal job of delivering the information in an engaging and informative manner. I can’t thank him enough for offering such valuable insights that have definitely enhanced my understanding in this topic. Hats off to him for crafting such a masterpiece!

  37. I appreciate you sharing this blog post.Really looking forward to read more. Awesome.

  38. Thanks again for the blog. Want more.

  39. It’s amazijg designed ffor mee too have a weeb page,
    which iss beneficial in favor of my experience.
    thankss admin

  40. Your home is valueble for me. Thanks!?

  41. It is actually a great and helpful piece of info. I?m glad that you just shared this helpful information with us. Please keep us up to date like this. Thank you for sharing.

  42. Very informative post.Much thanks again. Really Cool.

  43. I truly appreciate this blog article.Really thank you! Fantastic.

  44. Thanks so much for the article. Keep writing.

  45. A big thank you for your blog article.Thanks Again. Will read on…

  46. A big thank you for your post. Really Great.

  47. Thanks for the guidelines you have provided here. One more thing I would like to mention is that laptop memory needs generally increase along with other innovations in the know-how. For instance, if new generations of processor chips are introduced to the market, there is usually a related increase in the scale calls for of both computer memory plus hard drive space. This is because the software operated by these processors will inevitably surge in power to make new technology.

  48. Thanks so much for the blog.Really thank you! Really Great.

  49. I’ve noticed that credit repair activity really needs to be conducted with tactics. If not, you are going to find yourself damaging your standing. In order to succeed in fixing your credit rating you have to ensure that from this second you pay any monthly dues promptly prior to their appointed date. It really is significant simply because by not really accomplishing that area, all other steps that you will decide on to improve your credit position will not be helpful. Thanks for giving your suggestions.

  50. It’s remarkable in support of me to have a website, which is useful designed for my knowledge.
    thanks admin

  51. Terrific article! That is the kind of information that are meant to be shared around the internet.
    Shame on the search engines for not positioning this post higher!
    Come on over and consult with my web site . Thanks =)

  52. Now I am ready to do my breakfast, when having my breakfast coming yet again to read more news.

ランキング(週間)

  1. 1

    GA4 「ページ ロケーション」と「ページ パス と スクリーン クラス」何が違う?ドメインの有無以外にもパラメータの扱いに違いあり

  2. 2

    GA4の探索で「ページ別訪問数」を見ることは可能か?

  3. 3

    GA4 拡張計測機能の新顔「フォームの操作」 form_start, form_submit

  4. 4

    GA4のレポート画面の数値データは、イベント発生時から何時間後に確定するのか?

  5. 5

    GA4の指標「総ユーザー数」VS「アクティブ ユーザー数」

  6. 6

    【祝・GPT-4 が ChatGPT plus に登場記念!】アクセス解析コンサルタントが、GPT-4にCSVデータを渡して、データ解析結果のコメントを書いてもらう方法

  7. 7

    GA4で異なるドメイン(サブドメイン)の同一ページパスをドメイン付きで表示する

  8. 8

    YouTubeの概要欄に貼られたリンクをクリックしてサイトを訪れたユーザーを計測するために

  9. 9

    GA4 イベントタグの「詳細設定」に「e コマースデータを送信」が実装されました。

  10. 10

    GA4 クロスドメイン設定では、リンク先に「_gl」パラメータが付く。勝手なパラメータを付けるとエラーになるページは要注意

最近の記事

  1. 生成AIを調整してABテストを実装したら想像以上に早かった

  2. 無料で使えるABテストツールのバージョンアップを行いました

  3. 無料ABテストツール(and,B)のマニュアルを作成しました

カテゴリー

 
TOP