使用Google Analytics(分析)跟踪Fancybox(jQuery Lightbox)中的图像视图 [英] Tracking image views in Fancybox (a jQuery Lightbox) using Google Analytics
问题描述
我在这个网站上工作: http://www.vomero.co.uk/ Torquay.aspx 并希望跟踪图像的视图(在Fancybox图库中打开)。
我知道我可以向每个人添加一个onClick事件图像,但由于图库允许用户使用下一张/上一张图标查看所有图像,用户实际上不太可能点击每张图片。
有什么想法?
谢谢,Matt
我想我找到了一个很好的解决方案。
如果您只向fancybox()对象添加'onComplete'键传递您的谷歌分析自定义操作的值 - 它会记录一个自定义操作,每当fancybox的内容被完全加载时...
如果您将其添加到您的fancybox中,它会自动在My-Category下录制My-Action,并将链接标题用作标签:
'onComplete':function(){_ gaq.push(['_ trackEvent','My-Category','My-Action',this.title]);}
样本fancybox调用:
jQuery(document).ready(function(){
jQuery('a [rel = screenshots]')。fancybox({
'type':'image',
'transitionIn':'fade',
'transitionOut':'fade',
'onComplete':function(){_ gaq.push(''trackEvent','ComicBox','Screenshots' ,this.title]);}
});
});
从示例链接调用:
< a href =screenshots / screenshot_2.png =截图title =截图2target =_ blank>截屏2< / a>
上面的链接将在fancybox中打开图片,当图片完全加载时,它会触发Google Analytics这将在屏幕截图下记录一个新动作,标记为
屏幕截图2 - 所有这些都在名为ComicBox的自定义事件类别下 p
希望这有所帮助。 。
如果不是 - 请在 http://www.hauntly.com/ 查看我的实时代码
I am working on this site: http://www.vomero.co.uk/Torquay.aspx and would like to track views of the images (which open in a Fancybox gallery).
I know I could add an onClick event to each image, but since the gallery allows the user to view all the images using Next/Prev icons it is unlikely users will actually click each photo.
Any ideas?
Thanks, Matt
I think I found a good solution for this. If you only add 'onComplete' key to fancybox() object passing the value of your google analytics custom actions - it will record a custom action every time the content of fancybox is fully loaded...
If you add this to your fancybox, it will automatically record My-Action under My-Category, with the link title used as a label:
'onComplete':function(){_gaq.push(['_trackEvent','My-Category','My-Action', this.title]);}
Sample fancybox call:
jQuery(document).ready(function(){
jQuery('a[rel=screenshots]').fancybox({
'type':'image',
'transitionIn':'fade',
'transitionOut':'fade',
'onComplete':function(){_gaq.push(['_trackEvent','ComicBox','Screenshots', this.title]);}
});
});
called from a sample link:
<a href="screenshots/screenshot_2.png" rel="screenshots" title="Screenshot 2" target="_blank">Screenshot 2</a>
The link above will open the image in fancybox, when the image is fully loaded it will trigger google analytics which will record a new action under "Screenshots", labeled "Screenshot 2" - all this under custom events category called "ComicBox"
hope this helps.. if not - check my live code at http://www.hauntly.com/
这篇关于使用Google Analytics(分析)跟踪Fancybox(jQuery Lightbox)中的图像视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!