Not receiving Fragment in Google Analytics

断了今生、忘了曾经 提交于 2019-12-12 04:56:13

问题


I have a website like this: https://example.com/path1/path2/#!portal/1

I've inserted the script of ga and I've made the next modification in the code to receive the fragment (after hash #):

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

But when I check the ga page, in "Behavior/Behavior Flow/Site Content/All Pages" I only have: https://example.com/path1/path2/

I'm new in ga, am I doing something wrong?


回答1:


The code you have in your question will work just fine. I think there may have been a temporary glitch affecting hash URLs, but everything seems to be working now, so I'd just try it again.

Also, since it sounds like you're building an AJAX site, I'd recommend taking a look at the developer guide on tracking single page applications with Google Analytics:
https://developers.google.com/analytics/devguides/collection/analyticsjs/single-page-applications




回答2:


I had the same problem - overriding the page value didn't do anything, despite the fact that this is explicitly mentioned in the documentation.

I finally replaced the hash with another character (two actually I used a double slash //) in the tracking code and used a search-replace filter in the view settings to restore the hash character.

If anybody has a proper solution I'll take it in a jiffy, but this is at least a workaround that does the job.



来源:https://stackoverflow.com/questions/29133758/not-receiving-fragment-in-google-analytics

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