gpt4 book ai didi

javascript - 在 Google Analytics 中跟踪按钮点击作为目标

转载 作者:行者123 更新时间:2023-12-03 21:41:56 25 4
gpt4 key购买 nike

我的网站上有一个按钮,单击此按钮会显示一个电话号码。

HTML

<div class="call-wrapper-middle">
<button id="call-phone-middle"><i class="fa fa-phone"></i>Call us</button>
<div class="call-number-middle" style="display: block;"> <a href="tel:555" class="number">555</a></div>
</div>

使用以下 jQuery

(function($) {
$("button#call-phone-middle").click(function() {
$(this).hide();
$("div.call-number-middle").show();
});
})(jQuery);

这很好用。但我还希望在 Google Analytics 中跟踪按钮的点击次数作为目标。

所以我添加了href="/show/phonenumber-middle" onclick="javascript:pageTracker._trackPageview (‘Phonenumber Middle’);" target="blank"到按钮:

<div class="call-wrapper-middle">
<button href="/show/phonenumber-middle" onclick="javascript:pageTracker._trackPageview (‘Phonenumber Middle’);" target="blank" id="call-phone-middle"><i class="fa fa-phone"></i>Call us</button>
<div class="call-number-middle" style="display: block;"> <a href="tel:555" class="number">555</a></div>
</div>

并在 Google Analytics(分析)中添加了一个具有以下设置的目标:。

目标设置:Custom
目标类型:Destination
目的地;等于:/show/phonenumber-middle

收到“根据您的数据,此目标的转化率为 0%”,并且实时报告中没有任何对话。

我的猜测是 <button> 有问题但我不知道。

最佳答案

我会为此使用 Google Analytics事件Here is the documentation for a GA click event 。然后在目标中,您可以将目标类型设置为事件,并且可以通过类别、操作或标签属性来跟踪它

<div class="call-wrapper-middle">
<button href="/show/phonenumber-middle" onclick="__gaTracker('send', 'event', 'buttons', 'click', 'phone-number-middle');" target="blank" id="call-phone-middle" style="display: none;"><i class="fa fa-phone"></i>Call us</button>
<div class="call-number-middle" style="display: block;"> <a href="tel:555" class="number">555</a></div>
</div>

关于javascript - 在 Google Analytics 中跟踪按钮点击作为目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31673991/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com