Javascript 问题:如何更新 LightBox Slideshow 1.1 中的 Google Analytics 代码
我在我的网站上使用 Lightbox Slideshow 1.1 (www.justinbarkhuff.com/lab/lightbox_slideshow),它使用 javascript 在模式窗口中显示照片,并且它的 javascript 文件中内置有 Google Analytics 选项,但它使用旧的顽童追踪器代码。我对修改javascript非常不熟悉。我想知道是否有人可以帮助我将这段代码从旧的 urchintracker 转换为新的异步代码。有关迁移到新代码的更多信息,请访问 - http:// code.google.com/apis/analytics/docs/tracking/asyncMigrationExamples.html
相关 lightbox.js 文件中的代码是
if(this.options.googleAnalytics){
urchinTracker(this.imageArray[this.activeImage].link);
}
: “(this.imageArray[this.activeImage].link)”是传递当前正在查看的图像的路径和文件名的变量(即“p/image1.jpg” >") 到 Google Analytics。这效果很好,我的 Google Analytics 接收数据正常,但我需要转换为最新的异步代码。
我想在新代码中转换为事件跟踪器,因此我需要它而不是仅发送urchinTracker('p/image1.jpg');改为:(
_gaq.push(['_trackEvent', 'Photos', 'View', 'currentimage.jpg']);
其中“currentimage.jpg”是 lightbox.js 文件中“(this.imageArray[this.activeImage].link);”传递的值。
(“_gaq.push”是新的“urchintracker”)
要查看 lightbox.js 文件,请访问:http://www.justinbarkhuff.com/lab/lightbox_slideshow/lightbox.js 并搜索 如果任何了解Javascript
会非常感激。
的人可以帮助我转换上面的代码,以便我可以使用 Google Analytics 的最新代码,或者如果您能给我指出正确的方向,我 想知道.. 难道就这么简单吗?
if(this.options.googleAnalytics){
_gaq.push(['_trackEvent', 'Photos', 'View', this.imageArray[this.activeImage].link]);
}
this.imageArray[this.activeImage].link 周围的 ' 符号怎么样?脚本会自动传递它们而不需要我将它们添加到代码中吗?
预先感谢您的任何和所有帮助!
I am using Lightbox Slideshow 1.1 (www.justinbarkhuff.com/lab/lightbox_slideshow) on my site which uses javascript to display photos in a modal window and it has a Google Analytics option built-in to its javascript file, but it uses the old urchintracker code. I'm very unfamiliar with modifying javascript. I was wondering if anyone could help me transform this code from the old urchintracker to the new Asynchronous code. More info on migrating to that new code can be found here - http://code.google.com/apis/analytics/docs/tracking/asyncMigrationExamples.html
The code in the lightbox.js file in question is:
if(this.options.googleAnalytics){
urchinTracker(this.imageArray[this.activeImage].link);
}
With "(this.imageArray[this.activeImage].link)" being the variable which passes the path and filename of the image currently being viewed (i.e. "p/image1.jpg") to Google Analytics. This works great and my Google Analytics is receiving data fine, but I need to convert to the latest Asynchronous code.
I want to convert to an Event tracker in the new code, so instead of the script just sending urchinTracker('p/image1.jpg'); I would need it to be instead:
_gaq.push(['_trackEvent', 'Photos', 'View', 'currentimage.jpg']);
(Where "currentimage.jpg" is the value passed by "(this.imageArray[this.activeImage].link);" in the lightbox.js file.
("_gaq.push" is the new "urchintracker")
To view the lightbox.js file, go to: http://www.justinbarkhuff.com/lab/lightbox_slideshow/lightbox.js and search for "urchintracker".
If anyone who knows Javascript could help me transform this above code so I can use the latest code for Google Analytics, I'd really appreciate it. Or if you could point me in the right direction. Thanks in advance.
I wonder..
could it be as simple as this?
if(this.options.googleAnalytics){
_gaq.push(['_trackEvent', 'Photos', 'View', this.imageArray[this.activeImage].link]);
}
What about the ' symbols around this.imageArray[this.activeImage].link? Will the script automatically pass them on without me adding them to the code?
Thanks in advance for any and all help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的。你的代码被很好地采用了。尝试一下;假设它以前可以工作,那么现在应该可以工作。
Yes. Your code is perfectly well adopted. Try it out; assuming it was working before, it should work now.