javascript - 使用Java for Intercom创建/更新销售线索?

标签 javascript intercom unbounce

我们想通过Javascript创建/更新对讲中的潜在客户,我们可以通过PHP来完成,但是我不知道如何使用Javascript进行操作,因为我们使用的是Unbounce登陆页面,当访客填写表单时,希望将其发送给对讲机并为我们创建销售线索。

我们可以在Unbounce中使用Zapier集成,但是不允许传递UTM参数,因此我们想直接使用Intercom API / Javascript。

以下是我们用于通过WP Intercom API创建销售线索的PHP脚本

有人使用Javascript怎么做?因此我可以放入“退信”页面脚本管理器。

$client = new IntercomClient('xxxxxxxxxxxxx=', null);

try {

    // First check if this already exists
    $leads = $client->leads->getLeads(['email' => $post['email']]);
    foreach ($leads->contacts as $lead) {
        $id = $lead->id;
    }

    if(!$id) {
        $id = '';
    } 

    $client->leads->update([
        "id" => $id,
        "email" => $post['email'],
        "name" => preg_replace("/[^a-zA-Z0-9\s]/", "", ucwords($post['first_name'])),
        "last_request_at" => time(),
        "last_seen_ip" => $_SERVER['REMOTE_ADDR'],
        "utm_campaign" => $post['Utm_campaign], 
        "utm_content" => $post['Utm_content'], 
        "utm_medium" => $post['Utm_medium'], 
        "utm_source" => $post['Utm_source'],
        "utm_term" => $post['Utm_term'],
        'Form Message' => preg_replace("/[^a-zA-Z0-9\s]/", "", $post['description'])]
    ]);

} catch(ClientException $e) {
    $response = $e->getResponse();
    $statusCode = $response->getStatusCode();
    if ($statusCode == '404') {
        // Handle 404 error
        return;
    } else {
        throw $e;
    }
}

最佳答案

您只需通过对讲javascript代码段传递用户信息,即可自动创建或更新销售线索。下面是一个示例脚本:

Intercom('boot', {
    app_id: '<app_id>',
    id: user_id,
    name: "User Name",
    email: user_email,
    created_at: user_creation_time,
    company: {
      id: company_id,
      website: web_url,
      created_at: company_creation_time,
    }
});


您可以在此处找到有关Intercom Javascript API的更多信息-https://developers.intercom.com/installing-intercom/docs/intercom-javascript

关于javascript - 使用Java for Intercom创建/更新销售线索?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57495708/

相关文章:

javascript - 类型错误 : Cannot read property 'src' of undefined when loading script in React Enzyme

node.js - 如何使用 Axios 限制/速率限制请求以防止 429 错误

android - 升级Intercom SDK会导致一堆 “Error:(6) Error retrieving parent for item: No resource found that matches the given name”错误

css - 退回样式表不起作用

javascript - 如何制作没有下一个按钮的多表单?

javascript - 覆盖 jQuery 选项卡 CSS

javascript - 如何在 Chrome 浏览器控制台中提交包含输入值的表单?

php - Div 高度不会根据子控件自动扩展

javascript - 每次更新路由时调用一个函数 vue.js