誰かがGoogleAnalyticsから空のクエリ文字列パラメータを削除する方法を知っているかどうか疑問に思っていましたか?
URLの例は次のようになります:http ://www.domain.com/index.asp?a = test&b = test&c =&d = test
この例では、「c」が空であるため、GoogleAnalyticsで「c」を除外する必要があります。
提供できる助けをありがとう!
誰かがGoogleAnalyticsから空のクエリ文字列パラメータを削除する方法を知っているかどうか疑問に思っていましたか?
URLの例は次のようになります:http ://www.domain.com/index.asp?a = test&b = test&c =&d = test
この例では、「c」が空であるため、GoogleAnalyticsで「c」を除外する必要があります。
提供できる助けをありがとう!
@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);
})();
見る:
"http://www.domain.com/index.asp?a=test&b=test&c=&d=test".match(/[^\=\&\?]+=[^\=\&\?]+/g)
--JavaScript
["a = test"、 "b = test"、 "d=test"]の配列を返す必要があります。