首页 > 解决方案 > 如何使用 iframe 在提交按钮上实现跟踪像素

问题描述

<iframe src="someUrl" scrolling="no" frameborder="0" width="1" height="1"></iframe>

想象一下我有 iframe,我们想通过它来跟踪我们网站上的注册活动,我们想在提交按钮上实现它,我应该怎么做?我应该只是在提交按钮内添加这个 iframe,还是有其他方法,我的意思是,见下文

<button type="submit">
  Text
<iframe src="someUrl" scrolling="no" frameborder="0" width="1" height="1"></iframe>
</button>

标签: javascript

解决方案


按钮内部不允许使用 iframe……但无论如何都没有理由在其中放置一个。

跟踪像素用于检测页面何时加载

尝试将它们放在页面的任何特定部分是没有意义的。

如果您想跟踪表单何时提交:

  • 将跟踪像素放在表单提交到的页面上
  • 使用基于 JS 的跟踪器来响应按钮上的点击事件或表单的提交事件

推荐阅读