Cookiesdirective and Statcounter

Cookiesdirective and Statcounter

本文关键字:Statcounter and Cookiesdirective      更新时间:2023-09-26

我已经实现了cookiesdirective.js,它可以在cookiesddirective.com中找到,并且Statcounter代码不起作用。我正在使用以下代码(DoYourOwnSite,标准):

var sc_project=9181072; 
var sc_invisible=1; 
var sc_security="328a83d2"; 
var scJsHost = (("https:" == document.location.protocol) ? "https://secure." : "http://www."); 
document.write("<sc"+"ript type='text/javascript' src='" + scJsHost + "statcounter.com/counter/counter.js'></"+"script>"); 

由于cookiesdirective.js需要删除标签,我已经删除了它们,但它仍然不起作用。另一方面,Google Analytics的代码运行起来没有问题。我确信这是关于更改代码,使其在另一个javascript中工作,但我现在不知道如何做到这一点。

谢谢,Goran

已解决。我不得不稍微更改一下statcounter代码:

var sc_project=xxxxxxxxxx; 
var sc_invisible=1; 
var sc_security="xxxxxxxxxxx"; 
var imported = document.createElement('script'); 
imported.type = 'text/javascript'; 
imported.async = true;
var scJsHost = (("https:" == document.location.protocol) ? "https://secure." : "http://www.");
imported.src = scJsHost + "statcounter.com/counter/counter_xhtml.js";
var s = document.getElementsByTagName('script')[0]; 
s.parentNode.insertBefore(imported, s);

无论如何,谢谢。