【问题标题】:How to track event for Event Tracking Activecampaign如何为 Event Tracking Activecampaign 跟踪事件
【发布时间】: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


【解决方案1】:

您必须使用 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
  });
});

【讨论】:

  • 您好,感谢您的回复。你有任何关于“数据”部分的例子吗?
  • data :{actid: "Actid", key: "key", event: "event_name", visit: ["v1","v2","v3"]}
  • 再次感谢您的回答。我想我有最后一个问题。对于访问部分,如果我想设置一个email变量,我可以只设置一个特定的email变量来触发事件吗?例如,如果我想知道谁访问了我的页面并触发了我的页面上的事件,我如何知道是谁(电子邮件)触发了我的页面上的事件?
  • 我认为,那么您将不得不通过电子邮件并在 PHP 端捕获它,或者您可以在用户登录时设置会话变量并在您的 PHP 脚本中访问它!
  • 非常感谢您的耐心等待。实际上,我想捕捉谁在没有用户登录的情况下访问了我的页面,也不想只捕捉我在编码中确定的特定电子邮件。是否有其他方法可以做到这一点?
猜你喜欢
  • 2020-02-18
  • 1970-01-01
  • 2011-12-14
  • 2015-01-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-30
  • 1970-01-01
相关资源
最近更新 更多