【问题标题】:Send server side Google Analytics data without sending server location发送服务器端 Google Analytics 数据而不发送服务器位置
【发布时间】:2019-09-08 09:13:06
【问题描述】:

我正在使用 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);
}

【问题讨论】:

    标签: javascript node.js google-analytics server-side measurement-protocol


    【解决方案1】:

    如果您有用户 ip,您可以使用 user ip override,然后应根据 ip 确定位置(与 aip 参数一样匿名)。

    为此目的专门构建的是geographical override。更难实现,因为您需要自己确定geo id 并通过您的请求传递它。

    【讨论】:

      【解决方案2】:

      我会将其移至客户端 javascript。

      假设您正在为购买处理发出 Ajax 请求,如果它返回成功 - 触发测量协议事件。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-07-21
        • 2015-02-10
        • 2019-02-27
        • 2010-12-03
        相关资源
        最近更新 更多