我想将我的Google Analytics代码添加到Drupal站点而不使用模块。我阅读了与此相关的主题,但无法在我的网站上完成。我想把我的代码放在<head></head>
标签中。这里是我的代码:如何将Google Analytics(分析)代码添加到Drupal 7
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
_gaq.push(['_setDomainName', 'example.com']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
任何特定的原因,你为什么要这样做,而不使用模块? –
我也很好奇。我看不到有理由不使用该模块,但是有理由使用某个模块(例如,如果Google分析脚本中有任何更改,模块可以更新嵌入的脚本) – Isaac
如果您想要验证为在其他一些Google服务(例如Search Console)中拥有某个网站的所有者,您需要在“head”标签内部使用Google Analytics代码。 – maciek