Tracking Hashtags & Querystrings in GA

只谈情不闲聊 提交于 2019-11-30 21:37:05

You can use a combination of _setAllowAnchor and _setCampMediumKey to force Google Analytics to (a) use your hash tag as a query string and (b) use your 'qr' in place of the normal utm _medium (or any other of the campaign variables).

More here : http://code.google.com/apis/analytics/docs/gaJS/gaJSApiCampaignTracking.html

Yahel

Google Analytics's default implementation ignores the anchor, ie, everything after #, so you need to pass through the value manually. _trackPageview can accept a 2nd parameter that allows you to pass pageview values manually.

By default, GA's pageview is just location.pathname+location.search. So, all you need to do is pass through that with location.hash.

_gaq.push(["_trackPageview",location.pathname + location.search + location.hash]);

Universal Analytics

With the newer UA API, the command should be:

ga('send', 'pageview', { 'page': location.pathname + location.search + location.hash});

Update

In the new analytics.js it should be

ga('create', 'UA-XXXX-Y', {'allowAnchor': true});

No web server can track hash tags. They aren't sent to the server; they're only used by the client.

You could always just encode http://.../qr and have your server redirect to your home page. Or just have it serve up the same content as the home page in response. Or go through a shortener.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!