Javascript jquerylive+;谷歌分析
我正在使用以下函数使用Ajax重载我的网站url链接:Javascript jquerylive+;谷歌分析,javascript,jquery,google-analytics,live,disqus,Javascript,Jquery,Google Analytics,Live,Disqus,我正在使用以下函数使用Ajax重载我的网站url链接: $(document).ready(function() { $('.insite').live("click", function(ev) { if ( history.pushState ) history.pushState( {}, document.title, $(this).attr('href')); ev.preventDefault(); $('#content')
$(document).ready(function() {
$('.insite').live("click", function(ev) {
if ( history.pushState ) history.pushState( {}, document.title, $(this).attr('href'));
ev.preventDefault();
$('#content').fadeOut().load($(this).attr('href')+' #content', function() {
$(this).fadeIn();
});
});
});
我想知道是否有可能将Google Analytics跟踪和Disqs加载集成到该功能中。
这是我尝试加载Disqs的代码,但出于某些原因,它加载了来自其他网站的评论:
window.disqus_no_style = true;
$.getScript("http://disqus.com/forums/mnml/embed.js")
谢谢您可以将Google Analytics功能直接放在事件调用中,将新的虚拟URL放在第二个参数中
$(document).ready(function() {
$('.insite').live("click", function(ev) {
var href = $(this).attr('href');
if ( history.pushState ) history.pushState( {}, document.title, href);
ev.preventDefault();
$('#content').fadeOut().load(href+' #content', function() {
$(this).fadeIn();
_gaq.push(['_trackPageview', href ]);
});
});
});
(我已经编辑了在事件中缓存href
的函数,因为为每个调用固定的值启动3个(现在是4个)单独的jQuery对象是低效的。)