admin管理员组文章数量:1410682
I would like to apply event tracking in google analytics to facebook ments 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.
I would like to apply event tracking in google analytics to facebook ments 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.
Share edited Jun 11, 2011 at 22:18 Yahel 37.3k23 gold badges106 silver badges154 bronze badges asked Jun 10, 2011 at 22:06 Ramiro Jr. FrancoRamiro Jr. Franco 2864 silver badges13 bronze badges1 Answer
Reset to default 7You can use the Facebook JS SDK Event Subscriptions, specifically ment.create
event callback.
FB.Event.subscribe('ment.create', function(response){
_gaq.push(["_trackEvent", "Facebook Comment", "Posted", response.mentID]);
});
You can also track ment deletions with ment.remove
FB.Event.subscribe('ment.remove', function(response){
_gaq.push(["_trackEvent", "Facebook Comment", "Deleted", response.mentID]);
});
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 mentID
, as well as a href
attribute, and a parentCommentID
, if the ment is a reply to another ment (otherwise, it is set to undefined
).
The href
attribute's purpose is unclear, but its contents appear to be posed as follows:
http://www.facebook./plugins/ments_v1.php?app_id=[your-app-id]&xid=276&url=[encodeURIComponent(location.href)]
本文标签: javascriptWhat is the best way to track facebook comment widget in google analyticsStack Overflow
版权声明:本文标题:javascript - What is the best way to track facebook comment widget in google analytics? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744951475a2634109.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论