在 Google Analytics 中将按钮点击作为目标进行跟踪 [英] Track button click as goal in Google Analytics
问题描述
我的网站上有一个按钮,点击这个按钮会显示一个电话号码.
HTML
<button id="call-phone-middle"><i class="fa fa-phone"></i>给我们打电话</button><div class="call-number-middle" style="display: block;"><a href="tel:555" class="number">555</a></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"
到按钮:
<button href="/show/phonenumber-middle" onclick="javascript:pageTracker._trackPageview ('Phonenumber Middle');"target="blank" id="call-phone-middle"><i class="fa fa-phone"></i>给我们打电话</button><div class="call-number-middle" style="display: block;"><a href="tel:555" class="number">555</a></div>
并使用以下设置在 Google Analytics 中添加了一个目标:.
目标设置:自定义
目标类型:目的地
目的地;等于:/show/phonenumber-middle
获得根据您的数据,此目标的转化率为 0%"并且在实时报告中没有对话.
我的猜测是 有问题,但我不知道.
我会为此使用 Google Analytics 事件.这里是 GA 点击事件的文档.然后在目标中,您将目标类型设置为事件,您可以通过类别、操作或标签属性对其进行跟踪
<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>给我们打电话</button><div class="call-number-middle" style="display: block;"><a href="tel:555" class="number">555</a></div>
I have a button on my website, clicking on this button reveals a phonenumber.
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>
Using the following jQuery
(function($) {
$("button#call-phone-middle").click(function() {
$(this).hide();
$("div.call-number-middle").show();
});
})(jQuery);
This works great. But I also wish to track the clicks on the button as a goal in Google Analytics.
So I added href="/show/phonenumber-middle" onclick="javascript:pageTracker._trackPageview (‘Phonenumber Middle’);" target="blank"
to the button:
<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>
And added a goal in Google Analytics with the following settings:.
Goal setup: Custom
Goal type: Destination
Destination; Equals to: /show/phonenumber-middle
Getting "This Goal would have a 0% conversion rate based on your data" and in the Real Time report there is no conversations.
My guess is that something is wrong with the <button>
but I have no clue.
I would use a Google Analytics event for this. Here is the documentation for a GA click event. Then in goals, you would set your goal type to event, and you can track it via the Category, Action, or Label attributes
<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>
这篇关于在 Google Analytics 中将按钮点击作为目标进行跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!