更新dashboard meta_ads某些统计口径
This commit is contained in:
parent
d85791a740
commit
2f7a177a4a
@ -111,14 +111,19 @@ class AdsDashboardService
|
||||
COALESCE(SUM(d.assisted_purchases), 0) as assisted_purchases,
|
||||
COALESCE(SUM(d.last_clicked_purchases), 0) as last_clicked_purchases,
|
||||
COALESCE(SUM(d.clicks), 0) as clicks,
|
||||
COALESCE(SUM(d.outbound_clicks), 0) as outbound_clicks,
|
||||
COALESCE(SUM(d.spend) / 1000000, 0) as spend,
|
||||
COALESCE(SUM(d.impressions), 0) as impressions,
|
||||
COALESCE(SUM(d.adds_to_cart), 0) as adds_to_cart,
|
||||
COALESCE(SUM(d.purchases), 0) as purchases,
|
||||
COALESCE(SUM(d.onsite_purchase), 0) as onsite_purchase,
|
||||
COALESCE(SUM(d.offsite_purchase), 0) as offsite_purchase,
|
||||
COALESCE(SUM(d.purchases_all), 0) as purchases_all,
|
||||
COALESCE(SUM(d.tiktok_shop_conversion), 0) as tiktok_shop_conversion,
|
||||
COALESCE(SUM(d.platform_purchase), 0) as platform_purchase,
|
||||
COALESCE(SUM(d.purchases_value) / 1000000, 0) as purchases_value,
|
||||
COALESCE(SUM(d.onsite_purchases_value) / 1000000, 0) as onsite_purchases_value,
|
||||
COALESCE(SUM(d.offsite_purchases_value) / 1000000, 0) as offsite_purchases_value,
|
||||
COALESCE(SUM(d.platform_purchase_value) / 1000000, 0) as platform_purchase_value,
|
||||
COALESCE(SUM(d.tiktok_shop_conversion_value) / 1000000, 0) as tiktok_shop_conversion_value,
|
||||
COALESCE(SUM(d.revenue) / 1000000, 0) as revenue,
|
||||
@ -141,12 +146,12 @@ class AdsDashboardService
|
||||
'roas' => 'meta_roas',
|
||||
'cpc' => 'cpc',
|
||||
'cpm' => 'cpm',
|
||||
'meta_purchases' => 'platform_purchase',
|
||||
'web_purchases' => 'purchases',
|
||||
'purchases' => 'purchases_all',
|
||||
'meta_purchases' => 'onsite_purchase',
|
||||
'web_purchases' => 'offsite_purchase',
|
||||
'purchases' => 'platform_purchase',
|
||||
'meta_conversion_value' => 'platform_purchase_value',
|
||||
'web_conversion_value' => 'purchases_value',
|
||||
'conversion_value' => 'purchases_value',
|
||||
'conversion_value' => 'platform_purchase_value',
|
||||
'cpoc' => 'cpoc',
|
||||
'ctr' => 'ctr',
|
||||
'revenue_per_link_click' => 'revenue_per_link_click',
|
||||
@ -211,28 +216,34 @@ class AdsDashboardService
|
||||
$totalCost = (float)$data['total_cost'];
|
||||
$impressions = (int)$data['impressions'];
|
||||
$clicks = (int)$data['clicks'];
|
||||
$outbound_clicks = (int)$data['outbound_clicks'];
|
||||
$purchases = (int)$data['purchases'];
|
||||
$purchases_all = (int)$data['purchases_all'];
|
||||
$tiktok_shop_conversion = (int)$data['tiktok_shop_conversion'];
|
||||
$platform_purchase = (int)$data['platform_purchase'];
|
||||
$onsite_purchase = (int)$data['onsite_purchase'];
|
||||
$offsite_purchase = (int)$data['offsite_purchase'];
|
||||
$purchases_value = (float)$data['purchases_value'];
|
||||
$platform_purchase_value = (float)$data['platform_purchase_value'];
|
||||
$conversion_value = $platform_purchase_value; //meta的$conversion_value=$platform_purchase_value
|
||||
$tiktok_shop_conversion_value = (float)$data['tiktok_shop_conversion_value'];
|
||||
$web_conversion_value = (float)$data['web_conversion_value'];
|
||||
$meta_conversion_value = (float)$data['meta_conversion_value'];
|
||||
|
||||
// 计算指标
|
||||
$roas = ($spend == 0) ? 0 : $revenue / $spend;
|
||||
$meta_roas = ($spend == 0) ? 0 : $platform_purchase_value / $spend;
|
||||
$meta_roas = ($spend == 0) ? 0 : $conversion_value / $spend;
|
||||
$google_roas = ($spend == 0) ? 0 : $purchases_value / $spend;
|
||||
$ctr = ($impressions == 0) ? 0 : $clicks / $impressions;
|
||||
$cpoc = ($platform_purchase == 0) ? 0 : $platform_purchase_value / $platform_purchase;
|
||||
$cpa = ($purchases == 0) ? 0 : $spend / $purchases;
|
||||
$cpoc = ($outbound_clicks == 0) ? 0 : $spend / $outbound_clicks;
|
||||
$cpa = ($platform_purchase == 0) ? 0 : $spend / $platform_purchase;
|
||||
$google_cpa = ($platform_purchase == 0) ? 0 : $spend / $platform_purchase;
|
||||
$cpm = ($impressions == 0) ? 0 : ($spend * 1000) / $impressions;
|
||||
$cpc = ($clicks == 0) ? 0 : $spend / $clicks;
|
||||
$conversionRate = ($clicks == 0) ? 0 : $purchases / $clicks;
|
||||
$revenuePerLinkClick = ($clicks == 0) ? 0 : $revenue / $clicks;
|
||||
$revenuePerLinkClick = ($outbound_clicks == 0) ? 0 : $conversion_value / $outbound_clicks;
|
||||
|
||||
// 根据平台类型映射数据
|
||||
// 根据平台类型映射数据
|
||||
$platformKey = match ($platform) {
|
||||
1 => 'meta',
|
||||
2 => 'google',
|
||||
@ -286,6 +297,15 @@ class AdsDashboardService
|
||||
case 'cpc':
|
||||
$value = '$' . number_format($cpc, 2);
|
||||
break;
|
||||
case 'meta_conversion_value':
|
||||
$value = '$' . number_format($meta_conversion_value, 2);
|
||||
break;
|
||||
case 'web_conversion_value':
|
||||
$value = '$' . number_format($web_conversion_value, 2);
|
||||
break;
|
||||
case 'conversion_value':
|
||||
$value = '$' . number_format($conversion_value, 2);
|
||||
break;
|
||||
case 'conversion_rate':
|
||||
$value = $conversionRate;
|
||||
break;
|
||||
@ -310,6 +330,12 @@ class AdsDashboardService
|
||||
case 'platform_purchase':
|
||||
$value = number_format($platform_purchase);
|
||||
break;
|
||||
case 'onsite_purchase':
|
||||
$value = number_format($onsite_purchase);
|
||||
break;
|
||||
case 'offsite_purchase':
|
||||
$value = number_format($offsite_purchase);
|
||||
break;
|
||||
case 'clicks':
|
||||
$value = number_format($clicks);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user