使用 Google Analytics 进行 Javascript 覆盖/对话跟踪 [英] Javascript Overlay/Dialog Tracking with Google Analytics

查看:23
本文介绍了使用 Google Analytics 进行 Javascript 覆盖/对话跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 javascript(在我的情况下准确地说是 jQuery),我需要在 Google Analytics 中启用一个对话框作为唯一的页面视图进行跟踪,尽管它只是一个模式覆盖.

Using javascript (jQuery to be precise in my case) I need to enable a dialog box to be tracked in Google Analytics as a unique page view, despite it being only a modal overlay.

出于上下文目的,我不希望用户离开页面并通过 ajax 调用加载对话框内容.

For context purposes I dont want the user leaving the page and the dialog content is loaded in via an ajax call.

推荐答案

假设您使用的是 Google Analytics 的新异步代码,您需要做的就是将此代码放在呈现模态对话框的 JavaScript 块中.

Assuming you're using Google Analytics new async code, all you need to do is place this code in the JavaScript block where you render your modal dialog.

 _gaq.push(['_trackPageview', '/fake/modal/path/here']);

如果您使用的是旧代码,

If you're using the old code,

   pageTracker._trackPageview('/fake/modal/path/here');

<小时>

基本要点是您应该在绑定更改模式的事件事件的任何位置附加 _trackPageview 调用.如果您为多个模态浏览量执行此操作,则需要手动编码每个内部模态页面,或以编程方式命名它们.如果这些模式更改触发了 URL 哈希的更改,您可以尝试这种方法:跟踪目标渠道中的锚链接

这篇关于使用 Google Analytics 进行 Javascript 覆盖/对话跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆