通过ajax调用谷歌分析记录页面视图

时间:2022-03-25 15:23:17

I am logging page view through ajax action when my inner page content gets loaded. Issue is bounce rate data is not updated (always 0%)

当我的内页内容被加载时,我通过ajax操作记录页面视图。问题是跳出率数据未更新(始终为0%)

Default ga page view record logged from footer.

从页脚记录的默认ga页面视图记录。

<script>
 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-xxxx-1', 'auto');
  ga('send', 'pageview');

</script>

After this I am executing code to load inner page content then logging page view for this action.

在此之后,我执行代码以加载内页面内容,然后记录此操作的页面视图。

function gapPageView(hash)
{
   ga('send', 'pageview', { 'page': hash});
}

Page view entries are recorded successfully in google analytic and can seen in All pages report. / /step1

页面查看条目在Google解析中成功记录,可以在所有页面报告中看到。 / /步骤1

May time I visited same page and closed tab. removed browser cookies and open new session. But there is not data change in bounce rate of step1.

我可以访问同一页面并关闭标签。删除浏览器cookie并打开新会话。但步骤1的跳出率没有数据变化。

Please help me understand if I am missing something here.

如果我在这里遗漏了什么,请帮助我理解。

1 个解决方案

#1


0  

As I see it, you're firing two separate page views within the same page, to check that it's loaded properly.

在我看来,你在同一页面中触发两个单独的页面视图,以检查它是否正确加载。

Bounce Rate is the percentage of Sessions which Bounced. If you're looking at a page level, you only count as a Session if you arrived here first, and you only count as a Bounce if you began here, and then interacted no further (which will likely only register 30 minutes later, as it will hang on to the hope that you may interact again).

跳出率是跳出的会话的百分比。如果您正在查看页面级别,如果您先到达此处,则仅计为会话,如果您从此处开始,则仅计为退回,然后不再进行交互(这可能仅在30分钟后注册,因为它将继续希望你可以再次互动)。

This means that you can only count as a Bounce on the first page of the site that you saw, so it's impossible for somebody to bounce on the second page view.

这意味着您只能在您看到的网站的第一页上计为退回,因此某人无法在第二页视图上反弹。

Meanwhile the first page view will only be treated as a Bounce if there is no further interaction. Since you fire another page view almost immediately, it's almost impossible for a user to bounce on the first page view. They'd have to have avoided the second trigger somehow, such as because that part of the site didn't load, or perhaps that they closed the browser at the exact right time. This is unlikely to happen unless you have a lot of traffic to your site.

同时,如果没有进一步的互动,第一页视图将仅被视为弹跳。由于您几乎立即触发了另一个页面视图,因此用户几乎不可能在第一页视图上弹跳。他们必须以某种方式避免第二次触发,例如因为网站的那部分没有加载,或者可能是他们在恰当的时间关闭了浏览器。除非您的网站流量很大,否则不太可能发生这种情况。

#1


0  

As I see it, you're firing two separate page views within the same page, to check that it's loaded properly.

在我看来,你在同一页面中触发两个单独的页面视图,以检查它是否正确加载。

Bounce Rate is the percentage of Sessions which Bounced. If you're looking at a page level, you only count as a Session if you arrived here first, and you only count as a Bounce if you began here, and then interacted no further (which will likely only register 30 minutes later, as it will hang on to the hope that you may interact again).

跳出率是跳出的会话的百分比。如果您正在查看页面级别,如果您先到达此处,则仅计为会话,如果您从此处开始,则仅计为退回,然后不再进行交互(这可能仅在30分钟后注册,因为它将继续希望你可以再次互动)。

This means that you can only count as a Bounce on the first page of the site that you saw, so it's impossible for somebody to bounce on the second page view.

这意味着您只能在您看到的网站的第一页上计为退回,因此某人无法在第二页视图上反弹。

Meanwhile the first page view will only be treated as a Bounce if there is no further interaction. Since you fire another page view almost immediately, it's almost impossible for a user to bounce on the first page view. They'd have to have avoided the second trigger somehow, such as because that part of the site didn't load, or perhaps that they closed the browser at the exact right time. This is unlikely to happen unless you have a lot of traffic to your site.

同时,如果没有进一步的互动,第一页视图将仅被视为弹跳。由于您几乎立即触发了另一个页面视图,因此用户几乎不可能在第一页视图上弹跳。他们必须以某种方式避免第二次触发,例如因为网站的那部分没有加载,或者可能是他们在恰当的时间关闭了浏览器。除非您的网站流量很大,否则不太可能发生这种情况。