I've been searching through the Google Analytics documentation, but I still don't understand how I should track page views for a single "page" site that uses ajax to reveal different views. I use shebang URLs and _escaped_fragment_ to help search engines understand the site layout, but our analytics guy told me to strip out the #!
part of the URL when tracking, so when you visit mysite.com/#!/fish/bonker
we would run:
我已经搜索了谷歌分析文档,但是我仍然不明白如何跟踪一个使用ajax显示不同视图的“页面”站点的页面视图。我使用shebang url和_escaped_fragment_帮助搜索引擎理解站点布局,但是我们的分析人员告诉我去掉#!跟踪时URL的一部分,所以当您访问sitemy.com/ #时!/鱼/发出巨响,我们将:
_gaq.push(["_trackPageview", "/fish/bonker"]);
but that seems wrong to me. Wouldn't we want our tracked URLs to align with what Google actually spiders? Is there anything wrong with tracking _gaq.push(["_trackPageview", "#!/fish/bonker"]);
?
但这对我来说是错误的。难道我们不希望我们追踪的url与谷歌实际上的蜘蛛是一致的吗?跟踪_gaq有什么问题吗?推([“_trackPageview”," # ! /鱼/性交"]);?
1 个解决方案
#1
7
It's important to recognize that there is a wall between Google Analytics and Google Search. There's no reason you would be penalized by having your URLs in one not correspond to what the other sees.
重要的是要认识到谷歌分析和谷歌搜索之间有一道墙。你没有理由因为你的url与别人看到的不一致而受到惩罚。
escaped_fragment
is purely a semi-standard for crawlers seeking to crawl AJAX content.
escaped_fragment纯粹是爬行器抓取AJAX内容的半标准。
By default, Google Analytics does the equivalent when you don't pass a custom pageview value:
在默认情况下,谷歌分析在不传递自定义pageview值时也起到了同样的作用:
_gaq.push(["_trackPageview", location.pathname+location.search]);
If you want to have it also track the anchor
value, you can simply pass it on your own:
如果您想让它也跟踪锚点值,您可以自己传递它:
_gaq.push(["_trackPageview", location.pathname+location.search+location.hash]);
The benefit here is that the URLs will correspond with "real" URLs.
这里的好处是url将与“真实”url对应。
Long story short: You're perfectly fine doing your proposed method; I would prefer the latter (explicitly passing the actual location.hash
, not a hacked version of it), but both work.
长话短说:你完全可以按照你提出的方法去做;我更喜欢后者(显式地传递实际位置)。哈希,不是被黑的版本),但两者都可以。
#1
7
It's important to recognize that there is a wall between Google Analytics and Google Search. There's no reason you would be penalized by having your URLs in one not correspond to what the other sees.
重要的是要认识到谷歌分析和谷歌搜索之间有一道墙。你没有理由因为你的url与别人看到的不一致而受到惩罚。
escaped_fragment
is purely a semi-standard for crawlers seeking to crawl AJAX content.
escaped_fragment纯粹是爬行器抓取AJAX内容的半标准。
By default, Google Analytics does the equivalent when you don't pass a custom pageview value:
在默认情况下,谷歌分析在不传递自定义pageview值时也起到了同样的作用:
_gaq.push(["_trackPageview", location.pathname+location.search]);
If you want to have it also track the anchor
value, you can simply pass it on your own:
如果您想让它也跟踪锚点值,您可以自己传递它:
_gaq.push(["_trackPageview", location.pathname+location.search+location.hash]);
The benefit here is that the URLs will correspond with "real" URLs.
这里的好处是url将与“真实”url对应。
Long story short: You're perfectly fine doing your proposed method; I would prefer the latter (explicitly passing the actual location.hash
, not a hacked version of it), but both work.
长话短说:你完全可以按照你提出的方法去做;我更喜欢后者(显式地传递实际位置)。哈希,不是被黑的版本),但两者都可以。