Google Analytics:阻止发送页面标题

问题描述 投票:0回答:2

如何阻止 GA 跟踪页面标题?将

_setDetectTitle
设置为
false
仍会将请求中的页面标题发送到 GA 服务器 (
utmdt
)。由于隐私问题,我不希望页面标题离开浏览器。有什么想法吗?

javascript google-analytics
2个回答
7
投票

_setDetectTitle
对我来说工作得很好。你只需要在
_trackPageview
调用之前调用它:

    var _gaq=_gaq||[];
    _gaq.push(['_setAccount','UA-XXXXXX-1']);
    _gaq.push(['_setDetectTitle', false]);    
    _gaq.push(['_trackPageview'])

您可以将 _setDetectTitle 设置为 false 版本中发送的 __utm.gif 命中与 标准版本中发送的 进行对比。

在前者中,

utmdt
未设置,在后者中,则设置了。

截图:左边发送页面标题;右边的则不然。

Sends the page title Doesn't send the page title


2
投票

我尝试后效果很好。这是我正在使用的代码:

    <script type="text/javascript">
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
        _gaq.push(['_setDetectTitle', false]);
        _gaq.push(['_trackPageview']);

        (function () {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();
    </script>
© www.soinside.com 2019 - 2024. All rights reserved.