第三方 JavaScript 小部件的分析
我试图找到分析第 3 方 JavaScript 小部件的最佳方法 - 即分发给任意数量的任意用户的工具和内容,这些用户将小部件作为带有标签的 HTML 片段包含在内。
在同一域上
请注意,小部件不会加载到具有从外部站点加载的文档的 iframe 元素中。相反,它们将内容加载到主机页面的 DOM 中 - 即它们被视为与主机位于同一域。
对主机页面片段的分析
因此,本质上,我想跟踪统计信息(例如小部件视图、用户点击和自定义交互小部件),但我只想跟踪小部件的主页片段的统计信息。我不想跟踪小部件之外的主页上的点击。
我希望将统计信息整理在一起,以便站点 A 上的小部件的统计信息将与站点 B 和站点 C 等上的小部件的统计信息聚合。
问题
- 是否可以以满足这些要求的自定义方式使用 Google Analytics要求?或者是否无法将 GA 与主机页面上收集的其余数据分开?
- 如果可以使用 Google Analytics,那么如果主页已经使用 GA(具有不同的 GA 配置文件 ID)是否会出现问题,或者是否可以将它们安全地分开?
- 是否有其他适合小部件统计跟踪的分析包来满足这些要求?
- 或者,您还会如何解决获取这些小部件统计信息的问题?
I'm trying to find the best approach for analyics on 3rd party JavaScript widgets - i.e. tools and content that is distributed to any number of arbitrary users, who include the widgets as HTML snippets with tags.
On the same domain
Note that the widgets do not load into an iframe element that has a document loaded from the external site. Instead, they load content into the DOM of the host page - i.e. they are treated as being on the same domain as the host.
Analytics for a fragment of the host page
So, essentially, I want to track stats (such as widget views, user clicks and custom interactions within the widget), but I only want to track stats for the fragment of the host page that is the widget. I don't want to track clicks on the host page that are outside the widget.
I want the stats to be collated together, so that stats for the widget on site A will be aggregated with those of the widget on site B and site C, etc.
Questions
- Is it possible to use Google Analaytics in a custom way that satisfies these requirements? Or is it not possible to separate GA from the rest of the data collected on the host page?
- If it is possible to use Google Analytics, then will there be a problem if the host page already uses GA (with a different GA profile ID), or is it possible to keep them safely apart?
- Are there any other analytics packages out there that are properly suited to widget stats tracking, to meet these requirements?
- Or, how else would you approach the problem of obtaining stats for these widgets?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
GA 可以用于此目的,但由于它是一个免费工具,因此与其他工具相比它有一些限制。其他工具的示例包括 Yahoo Web Analytics (YWA)、Omniture SiteCatalyst 和 Webtrends。
大多数跟踪工具都能够进行自定义链接和“事件”跟踪。基本上,您要做的就是查找自定义链接跟踪所需的代码片段,并将其放入包装函数中以在 onclick 事件中执行(或添加事件侦听器等)。
您要做的第一件事是决定您想要为小部件提供哪些“事件”。您提到了计算“小部件视图”。这很容易做到:只需在嵌入小部件的页面上放置一段自定义代码即可。
但除此之外...单击任何按钮是否都算作单个事件?每个按钮是否代表不同的事件?等等...另外,是否有任何您想要与按钮关联的自定义值,例如产品 ID 或描述等。
在决定要跟踪的内容时要问自己的另一件重要事情是“这些数据的可操作性如何?”几乎没有什么是您无法跟踪的,但有很多事情对于做出真正的业务决策来说并不是很有用。
例如,听起来总体上您想要尝试测量用户与小部件的交互。我确信这个想法是要弄清楚它们对人们来说有多有用、有吸引力等等,这样你就可以弄清楚是否值得进一步开发它们,或者向它们扔钱或放弃它们。很公平。但请记住,活动要以目标为导向。了解用户单击按钮的次数并不是很有用,因为它本身并不具有可操作性。了解人们完成某个流程或步骤等的次数更具有可操作性。
一旦您列出了要跟踪的所有内容和时间,就可以开始构建自定义代码。
对于 GA,有两种主要方式来跟踪事件和指标:通过步骤/目标,以及通过自定义变量。使用 GA 设置步骤/目标的方法是让 GA 与页面的 URL 相匹配。例如,如果您有新闻通讯注册表单,则表单页面可能是signup.html,确认页面可能是signup_confirmation.html。然后,您可以在 GA 界面中设置一个目标。目标将与signup_confirmation.html 匹配,您可以采取一个步骤来查找signup.html。然后您可以看到有多少人查看了您的表单并完成了它,而不是放弃了它。
您可以通过将虚拟页面视图推送到 GA,对事件使用相同的跟踪方法。
以下文章详细介绍了如何推送虚拟页面视图:
http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=55521
但基本上,每当事件发生时(例如小部件的视图,单击按钮等..您将执行以下 javascript:
pageTracker._trackPageview('virtual url here');
关于此方法的主要注意事项是您可以通过传递分隔值来组织/分类/提供数据的层次结构。将帮助您汇总不同小部件/站点的数据。
记录事件的第二种方法是使用自定义变量。在事件期间使用自定义变量可以提供很多报告的可能性和灵活性:
http://code.google.com/apis/analytics/docs/tracking/gaTrackingCustomVariables .html
GA can be used for this, though since it is a free tool, it is a bit limited compared to the other tools out there. Example of other tools out there are Yahoo Web Analytics (YWA), Omniture SiteCatalyst, and Webtrends.
Most of the tracking tools out there have the ability to do custom link and "event" tracking. Basically what you would do is lookup the necessary snippet of code for custom link tracking and put it into a wrapper function to be executed in an onclick event (or add an event listener, etc..).
The first thing you want to do is decide what "events" you want to have for the widget(s). You mentioned counting "widget views". That's easy enough to do: just put a snippet of custom code on the page the widget is embedded on.
But beyond that...does clicking any button count as a single event? Does each button signify a different event? etc... Also, are there any custom values you want to associate with the buttons, like a product ID or description or whatever.
Another important thing to ask yourself when deciding on what you want to track is "How actionable is this data?" There is very little you can't track, but there are a lot of things that aren't very useful for making real business decisions.
For example, it sounds like overall you are wanting to try to measure user interaction with widgets. I'm sure the idea is to figure out how useful, engaging, etc... they are to people, so you can figure out whether it's worth further developing them or throwing money at them or dropping them. Fair enough. But just remember to make the events goal-oriented. Knowing how many times a user clicked a button isn't very useful because all by itself it isn't very actionable. Knowing how many times people completed a process or step, etc.. is more actionable.
Once you have made a list of what all you want to track and when, then you can start building your custom code.
With GA, there are 2 main ways to track events and metrics: through steps/goals, and through custom variables. The way you setup steps/goals with GA is to have GA match what the URL of the page is. For example, if you have a newsletter signup form, the form page might be signup.html and the confirmation page might be signup_confirmation.html. You would then setup a goal in the GA interface. The goal would match for signup_confirmation.html and you could have a step be to look for signup.html. Then you can see how many people viewed your form and completed it vs. abandoned it.
You can use this same tracking method with events, by pushing a virtual page view to GA.
Here is an article detailing how to push a virtual page view:
http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=55521
But basically, whenever the event happens (like a view of the widget, click of a button, etc.. you would execute the following javascript:
pageTracker._trackPageview(’virtual url here’);
Main thing to note about this method is that you can organize/categorize/provide hierarchy to your data by passing delimited values. This will help you rollup data for different widgets/sites.
The 2nd way to record events is with custom variables. Making use of custom variables during events provides a lot of reporting possibilities and flexibility. Here is a link to how to use them:
http://code.google.com/apis/analytics/docs/tracking/gaTrackingCustomVariables.html