dubture / customerio-bundle

将 customer.io 集成到 Symfony

安装次数: 19,985

依赖者: 0

建议者: 0

安全性: 0

星标: 3

关注者: 3

分支: 1

开放问题: 0

类型:symfony-bundle

0.0.1 2015-03-12 22:21 UTC

This package is not auto-updated.

Last update: 2024-09-14 16:18:56 UTC


README

Build Status Scrutinizer Code Quality

Latest Stable Version Total Downloads License

Symfony 集成 http://customer.io

配置

使用 composer 安装该包,并在 Kernel 中注册。

然后配置您的 site_idapi_key

# app/config/config.yml

dubture_customer_io:
  site_id: <YOUR-SITE-ID>
  api_key: <YOUR-API-KEY>

用法

客户模型

在您的客户领域类中实现 Dubture\CustomerIOBundle\Model\CustomerInterface

事件跟踪 / 客户识别

use Dubture\CustomerIOBundle\Event\TrackingEvent;
use Dubture\CustomerIOBundle\Event\ActionEvent;

/** @var \Symfony\Component\EventDispatcher\EventDispatcher $tracker */
$dispatcher = $this->getContainer()->get('event_dispatcher');

$customer = $someRepo->getCustomer(); // retrieve your customer domain object

// send the customer over to customer.io for identification
$dispatcher->dispatch(TrackingEvent::IDENTIFY, new TrackingEvent($customer));

// now track a `click` event
$dispatcher->dispatch(TrackingEvent::ACTION, new ActionEvent($customer, 'click'));

Webhooks

该包附带一个控制器,可以消费 customer.io webhooks

要使用它们,注册 routing.xml

# app/config/routing.yml

customerio_hooks:
    resource: "@DubtureCustomerIOBundle/Resources/config/routing.xml"

现在您的钩子 URL 将是 http://your.project.com//__dubture/customerio,您需要在 customer.io 中配置它。

完成后,您就可以监听 webhook 事件了

<service id="acme.webhooklistener" class="Acme\DemoBundle\Listener\WebhookListener">
    <tag name="kernel.event_listener" event="customerio.email_clicked" method="onClick" />
</service>
use Dubture\CustomerIOBundle\Event\WebHookEvent;

class WebhookListener
{
    public function onClick(WebHookEvent $event)
    {
        $this->logger->info('Customer clicked on email with address: '
        . $event->getEmail());
    }
}