43 lines
1.6 KiB
PHP
43 lines
1.6 KiB
PHP
<?php
|
|
header("Content-Type: application/json");
|
|
header("Access-Control-Allow-Origin: *");
|
|
// V85 LinkedIn->demo tracking - bumps linkedin_to_demo KPI from TBD to tracked
|
|
$log = '/opt/weval-l99/linkedin-demo-hits.jsonl';
|
|
$action = $_GET['action'] ?? 'stats';
|
|
|
|
if ($action === 'hit') {
|
|
$entry = [
|
|
'ts' => date('c'),
|
|
'ref' => $_SERVER['HTTP_REFERER'] ?? '',
|
|
'ua' => $_SERVER['HTTP_USER_AGENT'] ?? '',
|
|
'ip' => $_SERVER['REMOTE_ADDR'] ?? '',
|
|
'utm' => $_GET['utm_source'] ?? '',
|
|
'from_linkedin' => preg_match('/linkedin\.com/i', $_SERVER['HTTP_REFERER'] ?? '') ? 1 : 0,
|
|
];
|
|
@file_put_contents($log, json_encode($entry)."\n", FILE_APPEND);
|
|
echo json_encode(['ok'=>true,'tracked'=>true]);
|
|
exit;
|
|
}
|
|
// Stats
|
|
$month_start = strtotime(date('Y-m-01'));
|
|
$hits_month = 0; $from_linkedin = 0;
|
|
if (file_exists($log)) {
|
|
foreach (file($log) as $line) {
|
|
$e = @json_decode($line, true);
|
|
if (!$e) continue;
|
|
if (strtotime($e['ts']) >= $month_start) {
|
|
$hits_month++;
|
|
if ($e['from_linkedin'] ?? 0) $from_linkedin++;
|
|
}
|
|
}
|
|
}
|
|
echo json_encode([
|
|
'v' => 'V85-demo-tracker',
|
|
'month_hits_total' => $hits_month,
|
|
'linkedin_referrer_month' => $from_linkedin,
|
|
'target_per_month' => 30,
|
|
'status' => $from_linkedin >= 30 ? 'OK' : ($from_linkedin >= 10 ? 'PROGRESSING' : 'BELOW'),
|
|
'pixel_url' => 'https://weval-consulting.com/api/v85-demo-tracker.php?action=hit',
|
|
'integration' => 'Add <img src="..." width=1 height=1> in LinkedIn post CTAs landing pages',
|
|
], JSON_PRETTY_PRINT);
|