Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$firebaseAppId = '1:647662928949:ios:a1293fffeac32968565d7c';
$apiSecret = 'mUE2dHVNRayaFsMK_ZhSBw';
$appInstanceId = 'ffo6ZVcjeU1cm9WxiDOloG'; // замени на свой актуальный
$url = "https://www.google-analytics.com/mp/collect?firebase_app_id={$firebaseAppId}&api_secret={$apiSecret}";
$data = [
'app_instance_id' => $appInstanceId,
'events' => [[
'name' => 'purchase_test',
'params' => [
'value' => 49.99,
'currency' => 'USD',
'source' => 'php_test'
]
]]
];
$payload = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "HTTP Code: $status\n";
echo "Response: $response\n";