可以检测到“保存到口袋”吗?

时间:2016-05-04 19:40:01

标签: javascript google-analytics pocket

我希望能够跟踪有多少人从我的页面将文章保存到Pocket。我联系了Pocket支持,他们说Chrome扩展程序在点击时不会发出事件。我希望能够在发生这种情况时推动Google分析目标。

我从MDN MutationObserver文档一起攻击了以下内容,但它依赖于Pocket不更改其UI的类名。 (并将其留在DOM中,而不是单独的叠加层。)

var target = document.querySelector('body');

// create an observer instance
var observer = new MutationObserver(function(mutations) {
  mutations.forEach(function(mutation) {
    console.log(mutation);
    let a = document.getElementById('pkt_ext_master');
    if (a){
       console.log(a, "found a pocket save - firing a GA event!");
    }
  });    
});

// configuration of the observer:
var config = { attributes: true, childList: true, characterData: true };

// pass in the target node, as well as the observer options
observer.observe(target, config);

Pocket建议我查看他们的Publisher stats,这很好,但它是两个信息来源。有没有人对如何更优雅地做到这一点有所了解?它只是由Pocket支持吗?

0 个答案:

没有答案
相关问题