我正在尝试使用Google Analytics(UA)找出在我的网页中跟踪文件下载(特别是pdf文件)的最佳方法。我知道
select telephone, motive, complaint_id, complaint_date,
case classif when 'A' then 0 else 1 end
from test_data
match_recognize (
partition by telephone, motive
order by complaint_date, complaint_id
measures classifier() as classif
all rows per match
pattern ( a x* )
define x as complaint_date <= add_months(a.complaint_date, 2)
)
order by telephone, motive, complaint_date, complaint_id
;
我可以跟踪由(左)点击链接触发的事件。如何跟踪同一事件但是右键单击和中键单击操作?我不想按点击类型分隔事件,但只想更准确地衡量文件的下载次数。
我对此问题的第一次尝试是分别使用<a href="book.pdf" onClick="ga('send','event','PDF Downloads','Click','Book');">Download Book</a>
和oncontextmenu
进行右键和中键点击。所以我最终会得到类似的东西:
auxclick
但重复<a href="book.pdf" onClick="ga('send','event','PDF Downloads','Click','Book');"
oncontextmenu="ga('send','event','PDF Downloads','Click','Book');"
auxclick="ga('send','event','PDF Downloads','Click','Book');">
Download Book</a>
三次似乎非常混乱,容易出错。实现这一目标的最佳方式是什么?
聚苯乙烯。 ga('send','event','PDF Downloads','Click','Book');
跟踪中间点击事件有多好?
答案 0 :(得分:1)
$(document).on('mousedown', '.track', function(e){
//e.which 1 = left click, 2 = middle click, 3 = right click
//track by book url (http://example.com/book.pdf)
ga('send', 'event', 'PDF Downloads', 'Click', this.href);
//track by book title (Book Title 2)
ga('send', 'event', 'PDF Downloads', 'Click', $(this).data('book'));
//track by button contents (Download Book 2)
ga('send', 'event', 'PDF Downloads', 'Click', $(this).text());
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="book.pdf" class="track" data-book="Book Title 1">Download Book 1</a>
<a href="book.pdf" class="track" data-book="Book Title 2">Download Book 2</a>
&#13;