oscar-team / customerio-laravel
此包用于使用Laravel在Customer.io上创建客户和事件
2.0.3
2023-12-15 09:06 UTC
Requires
- php: >=8.0
- printu/customerio: ^3.5
README
此包用于为Customer.io上的客户创建/更新客户和事件。它使用 printu/customerio
包。
安装
composer require oscar-team/customerio-laravel
您还可以使用以下命令发布配置文件:
php artisan vendor:publish --tag=customerio-config
从Customer.io生成 站点ID
、API密钥
和 应用程序API密钥
,并在 .env
文件中设置变量。
CUSTOMER_IO_DEFAULT_WORKSPACE=VALUE CUSTOMER_IO_SITE_ID=VALUE CUSTOMER_IO_API_KEY=VALUE CUSTOMER_IO_APP_API_KEY=VALUE
如果您想要设置更多的工作空间以连接,则需要将它们复制并添加到 config/customerio.php
文件中的 workspaces
键中。每个工作空间都需要这三个键:api_key
、app_api_key
、site_id
。
使用方法
在您的 controller
中包含 use Oscar\CustomerioLaravel\Facade\CustomerIo;
并添加以下功能。
创建customer.io对象
$customerIo = CustomerIo::workspace();
或
$customerIo = CustomerIo::workspace('us_market');
通过电子邮件搜索客户
$isCustomer = $customerIo->searchCustomerByEmail($email);
创建客户
email
是创建客户所必需的,而 id
是可选的但不能为空。您可以添加更多您想要为客户添加的属性。
$customerData = [ 'id' => 1 'email' => 'demo@test.com', 'first_name' => 'john', 'last_name' => 'doe', ]; $customerIo->addCustomer($customerData);
更新客户
email
是创建客户所必需的,而 id
是可选的但不能为空。
$customerData = [ 'id' => 1 'email' => 'demo@test.com', 'first_name' => 'Doe', 'last_name' => 'John', ]; $customerIo->updateCustomer($customerData);
创建事件
在创建事件时,使用 id
或 email
将事件与客户关联起来。
$eventData = [ 'id' => 1 'email' => 'demo@test.com', 'name' => 'Event Created', 'data' => [] ]; $customerIo->createEvent($eventData);