使用Google Analytics而不发送查询字符串数据 [英] Using Google Analytics without sending query string data

查看:92
本文介绍了使用Google Analytics而不发送查询字符串数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用jQuery / AJAX网络在ASP.NET上执行Google Analytics的简单实现,其中大部分我们只需调用_trackPageview并让Google完成剩下的工作。



我们在查询字符串中进行了大量数据传输,最近管理层担心我们的很多数据(例如产品编号)都会发送给Google。没有讨论这是否应该是一个问题:



是否有可能在没有将查询字符串发送到Google服务器的情况下使用Google Analytics?我知道如何从实际报告中筛选出来,但我正在寻找一种方法来防止它通过网络发送。

解决方案是的,正如Litso所说的,你可以发送一个你想要的作为GA页面视图的路径名,但是你会想用JavaScript自动完成这个过程。

以下代码将采用当前URL的路径名(不包括查询字符串)并将其用作页面名称值。

  _gaq.push(['_ trackPageview',location.pathname]); 

或者相反,如果您使用的是旧的_gat代码,那么

  pageTracker._trackPageview(location.pathname); 

因此,如果您的网址 http://example.com/path/to/page.html?supersecretinfo ,它会在GA中被跟踪为/ path / to / page .html


We're doing a simple implementation of Google Analytics on our ASP.NET with jQuery/AJAX web, and for most of it we just call _trackPageview and let Google do the rest.

We do a lot of data transfer in query strings, and recently, management became concerned that a lot of our data (such as product numbers) would be sent to Google. Without discussing whether that should be a concern:

Is it possible to use Google Analytics at all without sending the query string to Google's servers? I know how to filter it out from the actual reports, but I'm looking for a way to prevent it from being sent over the wire at all.

解决方案

Yes, as Litso said, you can send a whatever you want as the pathname for a GA page-view, but you'll want to automate the process with JavaScript.

The following code will take the current URL's pathname (which excludes the query string) and uses it as the pagename value.

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

Or, conversely, if you're using the old _gat code,

  pageTracker._trackPageview(location.pathname);

So, if your URL is http://example.com/path/to/page.html?supersecretinfo, it will get tracked in GA as /path/to/page.html

这篇关于使用Google Analytics而不发送查询字符串数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆