0
我想從瀏覽器欄中刪除Google Analytics(分析)網址跟蹤代碼,以便當用戶複製/粘貼URL進行分享時,他們不會帶來所有跟蹤數據沒用,並且能夠歪曲道路上的數據。Google Analytics(分析)跟蹤
因此,我使用history.js來運行replaceState,以便在短暫暫停後基本消除URL中的跟蹤數據。
<script type="text/javascript">
setTimeout(function() {
if(window.location.search.indexOf("utm_campaign") >= 1) {
window.history.replaceState(null, document.title, window.location.pathname);
}
}, 1000);
</script>
有沒有人看到任何可能的併發症或使用這種方法的問題?
爲什麼你需要暫停? – 2012-08-13 18:34:16
我可以看到一個巨大的問題。它僅適用於HTML5瀏覽器:https://developer.mozilla.org/en-US/docs/DOM/Manipulating_the_browser_history#The_replaceState().C2.A0方法 – Tchoupi 2012-08-13 18:36:41
@MikeRobinson:我添加了暫停,以防GA遺傳跟蹤器當我運行它時,仍然從URL中提取信息。 – stevecomrie 2012-08-13 18:44:57