使用动态
我正在创建一个要在第三方网站上使用的 HTML/JavaScript 小部件。该小部件由
重要的是这个
-->我首先尝试简单地将 Clicky 跟踪代码附加到
http://onespot.wsj.com/ static/clicky_iframe_test.html
单击该测试页面上的链接时,该操作不会记录在 Clicky 中,并且会出现 JavaScript 错误:
clicky is not defined
此(“clicky”)似乎是在 http://static.getclicky.com/js,我在单击测试出站链接之前通过 Firebug 控制台确认确实正在加载。
有人用这种方法成功加载Clicky吗?如果是这样,您能否提供一些示例代码、工作实现的链接或有关我的代码有什么问题的一些反馈?我也有兴趣知道这是否可能。
非常感谢您的任何帮助或建议!
I'm creating an HTML/JavaScript widget to be used on third-party sites. This widget is generated by a <script> that our customers will insert on their page. The <script> creates an <iframe> in the customer's domain, and then creates and inserts all of that <iframe>'s content using JavaScript.
It's important that this <iframe> contain Clicky's tracking code to monitor clicks on outbound links. Unfortunately, I'm not having any luck getting Clicky to work when I append the requisite <script> elements to the <iframe> using JavaScript.
I first tried simply appending the Clicky tracking code to the <iframe> after appending some test outbound links, hoping that Clicky could attach to those automatically as it does on a static page. That didn't seem to work, so my next inclination was to use the "advanced_disable" custom option and use clicky.log() on the links I want to track. Here's a link to a test page that's along those lines:
http://onespot.wsj.com/static/clicky_iframe_test.html
When clicking a link on that test page, the action is not logged in Clicky, and a JavaScript error appears:
clicky is not defined
This ("clicky") appears to be defined in http://static.getclicky.com/js, which I confirmed through the Firebug console is indeed loading before I click a test outbound link.
Has anyone successfully loaded Clicky in this way? If so, could you provide some sample code, a link to a working implementation, or some feedback on what's wrong with my code? I would also be interested to know if this is even possible.
Thanks very much for any help or advice!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这经过进一步调试,变成了这个问题: 为什么附加一个
This got debugged further to morph into this question: Why does appending a <script> to a dynamically created <iframe> seem to run the script in the parent page?