0

想为在网站上花费一定时间的用户触发 Facebook Pixel 事件——就像谷歌分析如何理解谁是“参与用户”一样。目前似乎没有针对此的标准事件,也不会由像素自动记录。

4

1 回答 1

0

可以使用 Pixel 的trackCustom事件来跟踪自定义事件。在网站的某个地方(最好是在页面更改之间持续存在的 SPA),放置:

// set the interval's of interest (i.e. 10 secs, 30 secs, etc...)
const msIntervals = [10000, 30000, 60000, 90000, 120000, 180000]

const timers = msIntervals.map((ms) =>
  setTimeout(() => {
    window.fbq('trackCustom', 'TimeSpent', { ms })
  }, ms)
)

出于我自己的目的,我使用 React,所以在一个永远不会卸载的组件中执行以下操作:

useEffect(() => {
  const msIntervals = [10000, 30000, 60000, 90000, 120000, 180000]

  const timers = msIntervals.map((ms) =>
    setTimeout(() => {
      window.fbq('trackCustom', 'TimeSpent', { ms })
    }, ms)
  )

  return () => {
    for (const timer of timers) clearTimeout(timer)
  }
}, [])

于 2021-06-01T17:38:52.947 回答