javascript - Google Analytics 代码返回 'Undefined Function"错误

标签 javascript google-analytics

无论我做什么,我都会收到点击跟踪 Google Analytics(分析)代码的“未捕获的类型错误:未定义不是函数”错误。

页面是:http://www.purevisionmethod.com/eye-exercises/

请问,为什么会发生这种情况......?

<script>
$('#clicked-headerbar').on('click', function() {
  ga('send', 'event', 'website-banner', 'clicked-ad', 'headerbar', '0');
});
$('#clicked-cta-bottom').click( function() {
  ga('send', 'event', 'website-banner', 'clicked-ad', 'cta-bottom', '0');
});
$('#clicked-sidebar-image-ad-1').click( function() {
  ga('send', 'event', 'website-banner', 'clicked-ad', 'sidebar-ad-1', '0');
});
$('#clicked-sidebar-image-ad-2').click( function() {
  ga('send', 'event', 'website-banner', 'clicked-ad', 'sidebar-ad-2', '0');
});
$('#clicked-sidebar-image-ad-3').click( function() {
  ga('send', 'event', 'website-banner', 'clicked-ad', 'sidebar-ad-3', '0');
});
</script>

感谢您的帮助!!

最佳答案

该错误与 Google Analytics(分析)无关。

该错误是因为您在使用 jQuery 的代码之后包含了 jQuery 库。将此代码移至 jQuery 包含下方,或将 jQuery 包含移至此代码之前,它将起作用。

关于javascript - Google Analytics 代码返回 'Undefined Function"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26540792/

相关文章:

android - 将 Google Analytics 与 Android 应用集成

javascript - 如何让我的站点检测是否正在使用鼠标,然后在使用时向元素添加类?

javascript - 使用workbox的injectmanifest在vue.js中创建服务 worker 崩溃

javascript - 为什么 moment.js 只为某些日期生成无效日期?

iphone - 如何在 iPhone Titanium 应用程序中集成 Google Analytics

android - Google Analytics XML 配置文件与 JSON?

google-analytics - 如何在 Google Analytics 中实现唯一的自定义指标

php - Google Analytic API一般问题

javascript - 如何解决与 primefaces jquery 的冲突

javascript - 获取拖放区中选定文件的数量