text 更新Wordpress Google Analytics跟踪代码
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text 更新Wordpress Google Analytics跟踪代码相关的知识,希望对你有一定的参考价值。
<script>
var gaProperty = 'UA-XXXXXXXX-X';
var disableStr = 'ga-disable-' + gaProperty;
if (document.cookie.indexOf(disableStr + '=true') > -1) {
window[disableStr] = true;
}
function gaOptout() {
document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
window[disableStr] = true;
alert('Das Tracking ist jetzt deaktiviert');
}
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXXX-X', 'auto');
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');
</script>
\!h <!-- Alternative 2-->
function load_gatc() {
echo "<!-- Google Analytics Tracking Code -->
<script>
var gaProperty = 'UA-XXXXXXXX-X';
var disableStr = 'ga-disable-' + gaProperty;
if (document.cookie.indexOf(disableStr + '=true') > -1) {
window[disableStr] = true;
}
function gaOptout() {
document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
window[disableStr] = true;
alert('Das Tracking ist jetzt deaktiviert');
}
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXXX-X', 'auto');
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');
</script>
<!-- Google Analytics Tracking Code -->";
}
\!h add_action( 'wp_head', 'load_gatc' );
以上是关于text 更新Wordpress Google Analytics跟踪代码的主要内容,如果未能解决你的问题,请参考以下文章
text 更新Wordpress模板
text WP - 从登录屏幕更新WordPress徽标
text 这是一个小的PHP类,可以在不降低Pagespeed索引的情况下将Google分析添加到WordPress。它将analytics.js保存在服务器上
hosts 持续更新 - laod
PHP A / B拆分Google优化器for WordPress(过滤器挂钩)
如何更新 Wordpress ajaxurl 变量以使用 SSL?