为了账号安全,请及时绑定邮箱和手机立即绑定

为什么我的 Google Analytics callto 事件跟踪代码没有跟踪?

为什么我的 Google Analytics callto 事件跟踪代码没有跟踪?

陪伴而非守候 2021-10-21 15:03:56
我试图在单击按钮时跟踪呼叫电话事件。我的 GA 代码是从设置向导中提供的。<!-- Global site tag (gtag.js) - Google Analytics -->    <script async src="https://www.googletagmanager.com/gtag/js?id={{site.google_analytics_tracking_id}}"></script>    <script>        window.dataLayer = window.dataLayer || [];          function gtag(){dataLayer.push(arguments);}          gtag('js', new Date());          gtag('config', '{{site.google_analytics_tracking_id}}');    </script>我的按钮代码是:<!-- Banner --><section id="banner">    <div class="inner">        <header>            <h2>{{ site.title }}</h2>            <figure>                <picture class="image logo">                    <span class="icon logo fa-balance-scale"></span>                </picture>                <figcaption><small>Serving: {{ site.location }}</small></figcaption>            </figure>        </header>        <p><strong>We Work Hard To Protect Your Rights!</strong></p>        <footer>            <ul class="buttons stacked">                <button class="button fit">Call: <a href="tel:{{site.tel}}" onClick=”ga('send', 'event', 'Calls', 'clicked', 'Contact Office', 1);”>{{site.tel}}</a></button>            </ul>        </footer>    </div></section>投票请对问题投赞成票或反对票。在否决投票之前,建议编辑或发表评论?
查看完整描述

1 回答

?
墨色风雨

TA贡献1853条经验 获得超6个赞

您已经通过 gtag.js 实现了 GA,您用于 onClick 的函数用于 analytics.js,因此您需要使用正确的函数。您需要以这种格式执行此操作:


gtag('event', <action>, {

  'event_category': <category>,

  'event_label': <label>,

  'value': <value>

});

所以对于你的例子:


gtag('event', 'clicked', {

  'event_category': 'Calls',

  'event_label': 'Contact Office',

  'value': 1

});


查看完整回答
反对 回复 2021-10-21
  • 1 回答
  • 0 关注
  • 216 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信