将facebook iframe分享与谷歌分析相关联

时间:2015-10-16 18:51:56

标签: javascript facebook iframe google-analytics

我已成功将我的分析链接到跟踪Facebook事件。

跟踪喜欢和不喜欢的作品没有任何问题。分享按钮会出现问题,因为它是iframe。单击共享后,您将获得一个弹出窗口/ iframe,您可以在其中共享。有关如何更改此代码以跟踪共享事件的任何想法?或者代码需要在FB div中内联?这样每次点击都会推动ga?即使某人没有分享某些内容,这也只会计算共享按钮上的点击次数......

有什么想法吗?有人设法以某种方式实现这一目标吗?

无工作片段://我把它作为留言发送给我,对我没什么影响,所以这是故意的。

FB.Event.subscribe('message.send', function(targetUrl) {
_gaq.push(['_trackSocial', 'facebook', 'send', targetUrl]);});

所有代码:

window.fbAsyncInit = function () {
var like = function (url, html_element) {
    console.log("like");
};
var unlike = function (url, html_element) {
    console.log("unlike");
};
FB.Event.subscribe('edge.create', like);
FB.Event.subscribe('edge.remove', unlike);
FB.Event.subscribe('edge.create',function(targetURL) {
        ga('send', 'social', 'Facebook', 'like', targetURL);});
FB.Event.subscribe('edge.remove',function(URL) {
        ga('send', 'social', 'Facebook', 'unlike', URL);});
FB.Event.subscribe('message.send', function(targetUrl) {
    _gaq.push(['_trackSocial', 'facebook', 'send', targetUrl]);});
FB.Event.subscribe('comment.create',function(href) {
        ga('send', 'social', 'Facebook', 'comment added', href);});
FB.Event.subscribe('comment.remove',function(loc) {
        ga('send', 'social', 'Facebook', 'comment deleted', loc);});

};

谢谢。

0 个答案:

没有答案
相关问题