开发者

Tracking only the page, not the querystring

开发者 https://www.devze.com 2023-03-22 07:18 出处:网络
I\'m looking to track only the page the user visits, not the querystring (for pr开发者_高级运维ivacy reasons).

I'm looking to track only the page the user visits, not the querystring (for pr开发者_高级运维ivacy reasons).

Is this valid?

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

So a page that's:

x.com/section/page/?test=123

will be logged as

/section/page

Cheers


Yes, that will work perfectly fine. Passing that second argument will log a pageview using that value rather than the default value Google Analytics would be passing (location.pathname+location.search), and the pageviews will appear without the query string.


You can do it this way and NEVER pass the value to Google Analytics, or you can apply a filter in GA to exclude the part after the query string with a regular expression (I believe you even have the option in your Profile configuration now).

This might be more useful if you plan on using some query string parameters for other purposes - internal searches, user language, etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号