Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/438.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquerylive+;谷歌分析_Javascript_Jquery_Google Analytics_Live_Disqus - Fatal编程技术网

Javascript jquerylive+;谷歌分析

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')

我正在使用以下函数使用Ajax重载我的网站url链接:

$(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对象是低效的。)