简体   繁体   English

如何从Google Analytics(分析)跟踪中删除网站的基本网址?

[英]How to remove the base url of your website from Google Analytics trackings?

I've a question related to the simple tracking functionalities of Google Analytics. 我有一个与Google Analytics(分析)的简单跟踪功能有关的问题。

I've realized my website with reveal.js, so my site follows a step navigation 我已经通过reveal.js实现了我的网站,所以我的网站遵循了一步导航

http://[mywebsite.nl]/#/cover
http://[mywebsite.nl]/#/welkom
http://[mywebsite.nl]/#/pagina1
http://[mywebsite.nl]/#/pagina2

and I setup google analytics to track statistics. 我设置了Google Analytics(分析)来跟踪统计信息。

My tracking issue is that when I land on my http://[mywebsite.nl] and I'm redirected to http://[mywebsite.nl]/#/cover it happens that the same page is tracked twice. 我的跟踪问题是,当我登陆http:// [mywebsite.nl]并重定向到http:// [mywebsite.nl] /#/ cover时 ,碰巧同一页面被跟踪了两次。 Is there a way to remove the tracking of the / of the website? 有没有办法删除的网站/跟踪? Thanks 谢谢

You can take a look at Google's analytics.js tutorial, it allows some customization: https://developers.google.com/analytics/devguides/collection/analyticsjs/pages 您可以看一下Google的analytics.js教程,该教程可以进行一些自定义: https : //developers.google.com/analytics/devguides/collection/analyticsjs/pages

Page - The page path and query string of the page (eg /homepage?id=10). 页面-页面的页面路径和查询字符串(例如/ homepage?id = 10)。 This value must start with a / character. 此值必须以/字符开头。

GA is nice to use as is, it provides some valuable insights. GA可以按原样使用,它提供了一些有价值的见解。 But it is generally more valuable to track not page views but user actions. 但是通常更有价值的不是跟踪页面浏览,而是跟踪用户操作。 GA is about page views, but as soon as you really want to understand users behaviour you need to track actions. GA与页面浏览量有关,但是,一旦您真正想了解用户的行为,就需要跟踪操作。 I would recommend to take a look at http://www.devmetrics.io or http://mixpanel.com analytics. 我建议您看一下http://www.devmetrics.iohttp://mixpanel.com分析。

You specify event and its properties. 您指定事件及其属性。 That means that you have full control. 这意味着您拥有完全的控制权。

var pageName = document.location.pathname;
// custom pageName processing if you need
devmetrics.userEvent('page_load', [pageName]);
....
// inside button handler:
devmetrics.userEvent('button_click', [pageName]);

I wouldn't recommend stripping the hostname from your pageviews, that can cause other issues with data quality. 我不建议您从浏览量中删除主机名,否则可能导致数据质量出现其他问题。

Ideally, you would use a 3xx redirect to redirect from your main page to /#/cover, or don't send a hit before your site redirects. 理想情况下,您可以使用3xx重定向从主页重定向到/#/ cover,或者在网站重定向之前不发送匹配。 If that's not possible, you could try using a filter to drop hits from the URL you don't want to be double-counted. 如果无法实现,则可以尝试使用过滤器从您不想重复计算的网址中删除匹配。

You might try Google Tag Assistant Recordings to validate that your flow works as expected. 您可以尝试使用Google Tag Assistant记录来验证您的流程是否按预期工作。

It was easier than I thought, sometimes we tend to over complicate things.. This is the super easy answer I was looking for, it is necessary a small tune on the javascript code 这比我想象的要容易,有时我们会使事情变得过于复杂。。这是我一直在寻找的超级简单的答案,有必要在javascript代码上稍作调整

(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');

if(window.location.pathname != '/'){
  ga('create', 'UA-XXXXXXXXX', 'auto');
  ga('send', 'pageview');
}

It is just necessary to check the window.location.pathname and call the analytics function only for the desired urls. 仅需要检查window.location.pathname并仅针对所需的URL调用分析功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM