0

我想使用“curl”来使用“GA4 Event Builder”。

活动有效!

当我使用 curl 发送事件时,如果参数有问题,“validationMessages、fieldPath 等” 被退回。但是,当事件有效时,响应为

"{ "validationMessages": [ ] }"。

{"clientId":"1610256318","nonPersonalizedAds":false,"events":[{"name":"view_item","params":{"items":[{"item_id":"SD","item_name ":"SD_solution"}],"货币":"KRW"}}]}

$response = curl_exec($curl); curl_close($curl); echo $response; // { "validationMessages": [ ] }

网址https://www.google-analytics.com/debug/mp/collect?measurement_id=G-xxxx&api_secret=xxxx

当我看到它收到回复时,我认为它运作良好。但是,Google Analytics 调试视图中不会发生任何事件。

问题是什么?

$url="https://www.google-analytics.com/debug/mp/collect";
$url.="?measurement_id=".$vars['measurement_id'];
$url.="&api_secret=".$vars['api_secret'];
$fields_string=json_encode($payload); // $fields_string={"clientId":"1610256318","nonPersonalizedAds":false,"events":[{"name":"view_item","params":{"items":[{"item_id":"SD","item_name":"SD_solution"}],"currency":"KRW"}}]}
$curl = curl_init($url);
curl_setopt($curl,CURLOPT_POST, true);
curl_setopt($curl,CURLOPT_POSTFIELDS, $fields_string);       
curl_setopt($curl,CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($curl, CURLOPT_URL,$url);
curl_setopt($curl,CURLOPT_HTTPHEADER,array('Content-type: application/x-www-form-urlencoded'));
curl_setopt($curl,CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);            
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response  = curl_exec($curl);
curl_close($curl);
echo $response; //{ "validationMessages": [ ] }
4

0 回答 0