Tracking Hashtags & Querystrings in GA

前端 未结 4 830
野性不改
野性不改 2021-01-05 18:12

I have a few stickers which contain my website\'s URL QR Code (like this : http://qrcode.kaywa.com/img.php?s=5&d=http%3A%2F%2Fissocial.net%23qr) . I will stick it to str

4条回答
  •  一整个雨季
    2021-01-05 18:51

    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});
    

提交回复
热议问题