如何只过滤那些在GA中注册的交易ID?

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

我有一个包含 150 个交易 ID 的列表,我想检查一下哪些在谷歌分析中。然后使用 Measurement Protocol 想要覆盖它们。我知道如何在 Measurement Protocol 中覆盖它们,但我不知道如何首先过滤那些在 GA 中注册的 ID。

我的测量协议代码:

function gen_uuid()
{
    return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
        mt_rand(0, 0xffff), mt_rand(0, 0xffff),
        mt_rand(0, 0xffff),
        mt_rand(0, 0x0fff) | 0x4000,
        mt_rand(0, 0x3fff) | 0x8000,
        mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
    );
}
$data = array(
    'v' => 1,
    'tid' => 'UA-XXX',
    't' => 'transaction',
    'cid' => gen_uuid()
);


$data['ti'] = 12345;
$data['tr'] = '2206';
$data['ts'] = '149';
$data['tt'] = '0'; 
$data['cu'] = 'USD';


$url = 'https://www.google-analytics.com/collect';
$content = http_build_query($data);
$content = utf8_encode($content);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
$result = curl_exec($ch);
print_r($result);
curl_close($ch);

请帮忙

php google-analytics google-analytics-api measurement-protocol
© www.soinside.com 2019 - 2024. All rights reserved.