Ad

Send Server Side Google Analytics Data Without Sending Server Location

I am using Google Analytics client side.

Server-side I send e-commerce data and events to Google Analytics. However it's also sending the location of the server. Add the realtime overview I can see a lot of visitors in the same location where the server is located. My guess is that Google Analytics figures from the server-side events the user's location.

How can I prevent this?

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);
}
Ad

Answer

If you have the users ip you can use the user ip override, location should then be determined from the ip (which is anonymized the same way the aip parameter does).

Specifically build for the purpose is the geographical override. More difficult to implement, since you need to determine the geo id yourself and pass it in via your request.

Ad
source: stackoverflow.com
Ad