跟踪谷歌分析在1页网站使用标签

时间:2021-12-03 15:12:45

I have a long single page website using hashtags in the URL when you get to a certain section from scrolling or clicking. What technique can I use to track these hashtags as "pages" in google analytics?

我有一个很长的单页网站,在URL中使用标签,当你从滚动或点击到某个部分时。在谷歌分析中,我可以使用什么技术来跟踪这些标签作为“页面”?

3 个解决方案

#1


8  

(Recycling from a prior answer...)

(回收以前的答案…)

Generically, your code could look like this:

一般来说,您的代码可以如下所示:

_gaq.push(['_trackPageview',location.pathname + location.search  + location.hash]);

You could either bind that code to every time you have a hash change within your application, or you could use a generic hashchange plugin, that uses the HTML5 onhashchange, and some backwards compatible hacks for older browsers, and bind this code to that event, so that it fires every time your hash changes.

你可以将代码绑定到每次你有一个散列改变在您的应用程序,或者你可以使用一个通用的hashchange插件,使用HTML5 onhashchange,和一些对老版本浏览器的向后兼容的黑客,将这段代码绑定到事件,所以这大火每次你散列变化。

Using that plugin, your code could look like:

使用这个插件,您的代码可以如下所示:

$(window).hashchange( function(){
    _gaq.push(['_trackPageview',location.pathname + location.search  + location.hash]);

})

#2


3  

Yeah, virtual pageviews is your solution, here's the tutorial: http://services.google.com/analytics/breeze/en/et_vps/index.html

是的,虚拟页面视图是你的解决方案,这里有教程:http://services.google.com/analytics/breeze/en/et_vps/index.html

#3


0  

I believe you can use google analytics something like this

我相信你可以用谷歌分析像这样的东西

 onclick="javascript:_gaq.push(['_trackPageview','/PDF/EXAMPLE PDF NAME']);"

in your google analytics it will then record a click in the folder structure you specify

在谷歌分析中,它将在指定的文件夹结构中记录一次单击

#1


8  

(Recycling from a prior answer...)

(回收以前的答案…)

Generically, your code could look like this:

一般来说,您的代码可以如下所示:

_gaq.push(['_trackPageview',location.pathname + location.search  + location.hash]);

You could either bind that code to every time you have a hash change within your application, or you could use a generic hashchange plugin, that uses the HTML5 onhashchange, and some backwards compatible hacks for older browsers, and bind this code to that event, so that it fires every time your hash changes.

你可以将代码绑定到每次你有一个散列改变在您的应用程序,或者你可以使用一个通用的hashchange插件,使用HTML5 onhashchange,和一些对老版本浏览器的向后兼容的黑客,将这段代码绑定到事件,所以这大火每次你散列变化。

Using that plugin, your code could look like:

使用这个插件,您的代码可以如下所示:

$(window).hashchange( function(){
    _gaq.push(['_trackPageview',location.pathname + location.search  + location.hash]);

})

#2


3  

Yeah, virtual pageviews is your solution, here's the tutorial: http://services.google.com/analytics/breeze/en/et_vps/index.html

是的,虚拟页面视图是你的解决方案,这里有教程:http://services.google.com/analytics/breeze/en/et_vps/index.html

#3


0  

I believe you can use google analytics something like this

我相信你可以用谷歌分析像这样的东西

 onclick="javascript:_gaq.push(['_trackPageview','/PDF/EXAMPLE PDF NAME']);"

in your google analytics it will then record a click in the folder structure you specify

在谷歌分析中,它将在指定的文件夹结构中记录一次单击