问题
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