1

请问如何使用事件跟踪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);
    }
};
?>`

4

1 回答 1

0

您将不得不使用 AJAX 并发送请求以在要跟踪单击事件的所有按钮上执行此代码段。

$(".tracked-button").on('click', function () {
  // fire the AJAX request on button click
  $.ajax({
     type: "POST",
     url: 'YOUR URL',
     dataType: 'json',
     headers: {},
     data: {}
  })
  .done(function (response) {
     // if you want to do something on success
  })
  .fail(function (xhr, status, error) {
     // if you want to do something on error
  });
});
于 2021-10-12T03:03:18.037 回答