2

我们有一个 wordpress 网站,我们希望在有人浏览上述文章的 wordpress 画廊时进行跟踪。现在我们正在使用

<script>
  $("a[rel='gallery1']").colorbox({onComplete:function()
  {_gaq.push(['_trackPageview', $(this).attr('href')]);}}); 
</script> 

它工作正常,但似乎只适用于最初的开放。任何想法如何跟踪“下一个”和“上一个”点击?我们已经联系了 Colorbox 的开发者,但也想在这里发布。

4

1 回答 1

0

这应该适用于“下一个”和“上一个”命中。我不确定在手动跟踪浏览量时使用相对 URL 的情况如何。我认为这不是问题,但使用this.href而不是可能会更好$(this).attr('href'),因为这会给出绝对 URL 而不是 href 属性的确切值。例如:

<a href='../../pic1.jpg'>1</a>
<script>
    // for http://example.com/dir1/dir2/page.html
    $('a').attr('href'); // returns '../../pic1.jpg'
    $('a')[0].href; // returns 'http://example.com/pic1.jpg'
</script>
于 2012-08-18T02:56:49.823 回答