【问题标题】:Track iframe embeds of you webpage in GA在 GA 中跟踪您网页的 iframe 嵌入
【发布时间】:2014-03-23 06:02:07
【问题描述】:

我有一个托管 WebGL 可视化 (http://blocks.wizb.it) 的简单网页,我已经为它包含了基本的 Google Analytics(正常的 sn-p)。

一切都很好,但现在其他人正在将我的可视化嵌入到他们自己网站上的 iframe 中 (http://bitcoinvox.com/technology/mining/)。我现在完全不介意这一点,但是当我访问他们的页面时,访问并没有显示在 Google Analytics 下。在有关此主题的所有其他 SO 问题中,人们可以访问主机页面,而我没有。

是否可以完全跟踪这些访问?理想情况下,我还想查看 iframe 的嵌入位置(url)。

【问题讨论】:

    标签: javascript iframe google-analytics


    【解决方案1】:
    function trackMyPage(){
      if(window.top.location !== window.location){
       return window.top.location.href;  //tracked url
      }
    }
    

    您也可以使用其他形式来避免某些网站的保护:

    jsfiddle example

    【讨论】:

    • 好的,这样我就可以检测到被加载到 iframe 中。但是我不想阻止它,我想跟踪它。
    • window.top.location - 显示您的页面嵌入在哪个域中。 $(document).html - 例如。将其替换为您的跟踪代码。
    • 谢谢!我将尝试将其添加到 GA sn-p 中。当我弄清楚时会将其标记为已接受。
    猜你喜欢
    • 2015-09-17
    • 1970-01-01
    • 2014-05-02
    • 1970-01-01
    • 2023-03-22
    • 1970-01-01
    • 1970-01-01
    • 2018-02-14
    • 1970-01-01
    相关资源
    最近更新 更多