我想知道是否有人知道如何从Google Analytics中删除空的查询字符串参数?
示例网址为:http://www.domain.com/index.asp?a=test&b=test&c=&d=test
在此示例中,我希望Google Analytics过滤掉" c"因为它是空的。
感谢您提供的任何帮助!
答案 0 :(得分:0)
"http://www.domain.com/index.asp?a=test&b=test&c=&d=test".match(/[^\=\&\?]+=[^\=\&\?]+/g)
--JavaScript
应返回[“a = test”,“b = test”,“d = test”]的数组。
答案 1 :(得分:0)
支出@ user1494396;重构您的异步跟踪代码以从正则表达式传递页面名称,如下所示:
(function (window) {
function cleanQs() {
if (!window.location.search) {
return window.location.pathname;
}
var locSearchArr = window.location.search.match(/[^\=\&\?]+=[^\=\&\?]+/g);
var locPathName = window.location.pathname;
if (locSearchArr && locSearchArr.length > 0) {
locPathName += "?" + locSearchArr.join("&");
}
return locPathName;
}
var _gaq = window._gaq || (window._gaq = []);
window._gaq.push(['_setAccount', 'UA-XXXXX-X']);
window._gaq.push(['_trackPageview', cleanQs()]);
})(this);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
见: