【发布时间】:2021-11-30 16:30:53
【问题描述】:
请问如何用事件追踪ActiveCampaign代码来追踪特定事件?` 例如,如果我想跟踪我自己网站上的按钮点击,我该如何在这个 php 示例代码中添加。
谢谢。
<?php
// initializes a cURL session
$curl = curl_init();
// changes the cURL session behavior with options
curl_setopt($curl, CURLOPT_URL, "https://trackcmp.net/event");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, array(
"actid" => "Actid",
"key" => "Key",
"event" => "EVENT NAME",
"eventdata" => "Button click login",
"visit" => json_encode(array(
// If you have an email address, assign it here.
"email" => "",
)),
));
//execute
$result = curl_exec($curl);
if ($result !== false) {
$result = json_decode($result);
if ($result->success) {
echo 'Success! ';
} else {
echo 'Error! ';
}
echo $result->message;
} else {
echo 'cURL failed to run: ', curl_error($curl);
}
};
?>`
【问题讨论】:
-
curl用于在 PHP 中处理从您的域到另一个域的请求,因为您通常不能对不同的域进行 AJAX 调用。如果您在自己的网站中计算按钮点击次数,则根本不需要使用curl。
标签: php integration activecampaign