LoginSignup
0
0

More than 5 years have passed since last update.

analytics.jsからgtag.jsに移行したお話:クリックカウント編

Posted at

旧トラッキングコードとクリックカウント

旧トラッキングコード
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'GA_TRACKING_ID', 'auto');
ga('send', 'pageview');
</script>
旧クリックカウント
ga('send','event','カテゴリ','アクション','ラベル','値')

新トラッキングコードとクリックカウント

新トラッキングコード
<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'GA_TRACKING_ID');
</script>
新クリックカウント
gtag('event', 'アクション', {
  'event_category': 'カテゴリ',
  'event_label': 'ラベル',
  'value': '値'
});

新も旧もですが、値は任意でいいと思います。

参考サイト

gtag.js を使用してアナリティクスのトラッキングを設定する
Google アナリティクスのイベントをトラッキングする

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0