dubture / customerio-bundle
将 customer.io 集成到 Symfony
0.0.1
2015-03-12 22:21 UTC
Requires
- symfony/framework-bundle: >=2.3
- userscape/customerio: ~1.0
Requires (Dev)
- phpunit/phpunit: ~4.5
- symfony/browser-kit: ~2.2
- symfony/finder: ~2.2
- symfony/monolog-bundle: ~2.2
This package is not auto-updated.
Last update: 2024-09-14 16:18:56 UTC
README
Symfony 集成 http://customer.io。
配置
使用 composer 安装该包,并在 Kernel 中注册。
然后配置您的 site_id
和 api_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()); } }