【问题标题】:Google Analytics Event Tracking Code Not working谷歌分析事件跟踪代码不起作用
【发布时间】:2011-07-24 22:22:44
【问题描述】:

我正在使用 Google Analytics(分析)异步跟踪代码并尝试跟踪对 this download page 上“下载”按钮的点击。 (通常通过 Shadowbox 从其父页面 quitnowri.com 访问。)

在某一时刻,事件跟踪正在工作 - 我能够在我的报告中跟踪一个下载事件。

但后来,我将“下载”按钮更改为通过 php 使用 this method 强制下载。

standard event tracking JavaScript onClick handler 不起作用(在 said download page 上被注释掉了),所以我在跟踪事件时尝试使用 Google Analytics 中的函数到 delay pageload。这在 5 天后也没有用。

有什么想法吗?

【问题讨论】:

    标签: php javascript google-analytics analytics


    【解决方案1】:

    萤火虫老兄!

    【讨论】:

    • 这很尴尬。我会将“文件”放在引号中并试一试。似乎也需要升级我的 Firebug 插件。
    【解决方案2】:

    这确实是未定义的 JavaScript 变量的问题。解决办法是。

    在头脑中:

    <script type="text/javascript">
    
          var _gaq = _gaq || [];
          _gaq.push(['_setAccount', 'UA-XXXXXXXXX-1']);
          _gaq.push(['_trackPageview']);
    
          (function() {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
          })();
    
        </script>
        <!-- delay to ensure that events are tracked http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55527-->
        <script type="text/javascript">
          function recordOutboundLink(link, trackEvent, category, action) {
            _gat._getTrackerByName()._trackEvent(trackEvent, category, action);
            setTimeout('document.location = "' + link.href + '"', 100);
          }
        </script>
    <script type="text/javascript">
          function recordOutboundLink(link, trackEvent, category, action) {
            _gat._getTrackerByName()._trackEvent(trackEvent, category, action);
            setTimeout('document.location = "' + link.href + '"', 100);
          }
    </script>
    

    在链接上:

    <a href="download.php" id="download" class="download" name="Constant Reminder Ringtone" onClick="recordOutboundLink(this, 'Files', 'Download', 'Constant Reminder Ringtone');return false;">DOWNLOAD</a>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-26
      • 1970-01-01
      • 1970-01-01
      • 2014-02-15
      • 2014-04-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多