问题描述
我想通过Facebook社交插件(iframe小部件)在我们的网站上进行的Facebook评论中应用谷歌分析中的事件跟踪,但我似乎无法找到附加事件的方式。我宁愿如果解决方案是基于jQuery的,但诚实地说我对任何建议都是开放的。 您可以使用,特别是 comment.create 事件回调。 FB.Event.subscribe('comment.create',函数(响应){
_gaq.push([ _trackEvent,Facebook Comment,Posted,response.commentID]);
});
您还可以使用 comment.remove $ c $跟踪删除评论FB.Event.subscribe('comment.remove',function(response){
_gaq.push())
$ $ $ $ $ $ ([_trackEvent,Facebook Comment,Deleted,response.commentID]);
});
我已经测试过了,并且两者似乎都可以正常工作。如果您有任何问题,请尝试清除缓存,并确保检查。
如果您要异步加载Facebook SDK,应将这些调用置于异步回调函数中。如果您正在同步加载SDK,则只需将它们放在页面上比SDK更低。
响应对象将包含 commentID 以及 href 属性和 parentCommentID ,如果注释是对另一个注释的回复(否则,它被设置为 undefined $ c
href 属性的用途目前还不清楚,但它的内容似乎组成如下:
I would like to apply event tracking in google analytics to facebook comments made on our website via the facebook social plugin (iframe widget), but I can't seem to find a way to attach the event. I would prefer if the solution was jquery based, but honostly I'm open to most any suggestion.
You can use the Facebook JS SDK Event Subscriptions, specifically comment.create event callback.
FB.Event.subscribe('comment.create', function(response){ _gaq.push(["_trackEvent", "Facebook Comment", "Posted", response.commentID]); });
You can also track comment deletions with comment.remove
FB.Event.subscribe('comment.remove', function(response){ _gaq.push(["_trackEvent", "Facebook Comment", "Deleted", response.commentID]); });
I've tested this, and both appear to work reliably. If you have any troubles, try clearing your cache, and be sure to check the Facebook SDK Status Page.
If you're loading the Facebook SDK asynchronously, those calls should be placed in the asynchronous callback function. If you're loading the SDK synchronously, they just need to be placed lower on the page than the SDK.
The response object will have the commentID, as well as a href attribute, and a parentCommentID, if the comment is a reply to another comment (otherwise, it is set to undefined).
The href attribute's purpose is unclear, but its contents appear to be composed as follows:
这篇关于跟踪谷歌分析中的Facebook评论部件的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!