我正在使用 Google Analytics 客户端。
服务器端我将电子商务数据和事件发送到 Google Analytics。然而它也发送服务器的位置。添加实时概览我可以在服务器所在的同一位置看到很多访问者。我的猜测是,Google Analytics 根据服务器端事件计算出用户的位置。
如何防止这种情况发生?
var ua = require('universal-analytics');
function sendTransaction(analyticsProperty, {clientId, transactionId, profit}) {
const totalProfit = +profit.toFixed(2);
const visitor = ua(analyticsProperty, {
cid: clientId,
aip: 1
});
visitor.transaction(transactionId, totalProfit).send();
visitor.event('Transaction', 'Complete', '', totalProfit).send();
}
export function transactionCallback(transaction) {
sendTransaction('UA-XXXXXX-1', transaction);
}
最佳答案
如果您有用户 IP,您可以使用 user ip override ,然后应该根据 ip 确定位置(与 aip 参数一样,它是匿名的)。
专门为此目的构建的是 geographical override 。实现起来比较困难,因为您需要确定 geo id您自己并通过您的请求传递它。
关于javascript - 发送服务器端 Google Analytics 数据而不发送服务器位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57840594/