You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace juliang\conversion;
class Conversion extends Base
{
/**
* 事件回传
* @param string $event_type 事件类型
* @param string $callback
* @date 2022-12-14
*/
public function conversion($event_type, $callback)
{
// 获取毫秒级时间戳
list($msec, $sec) = explode(' ', microtime());
$msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
$url = $this->url;
$data = [
/* 回传的事件
active 激活 - 用户下载app完成激活行为
active_register 注册 - 用户在推广的应用/落地页场景下完成注册(手机号/微信等)行为
active_pay 付费 - 用户在推广的应用/落地页场景下发生交易并完成至少一笔付款,具体支付形式取决于广告主业务模式 */
'event_type' => $event_type,
// 包含一些关键的上下文信息
'context' => [
// 包含一些关键的广告相关信息
'ad' => [
// callback 字段有两个获取途径对于监测链接归因的方式需要从监测链接的__CALLBACK_PARAM__这个宏获取这个字段值对于落地页或小程序归因的方式需要从 url 中的 clickid 参数获取值
'callback' => $callback
],
// 事件发生的毫秒级时间戳
'timestamp' => $msectime
]
];
// 发送请求
$result = httpData($url, $data);
// 记录日志
$uid = defined('UID') ? UID : '';
platformLog($data, $result, 'juliang_conversion_uid_' . $uid);
return $result;
}
}