PHP code example of eonvisualmedia / laravel-klaviyo
1. Go to this page and download the library: Download eonvisualmedia/laravel-klaviyo library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
eonvisualmedia / laravel-klaviyo example snippets
Klaviyo::identify([
'email' => '[email protected] ',
'first_name' => 'Foo',
'last_name' => 'Bar'
]);
Klaviyo::push('track', 'Added to Cart', [
'$value' => 100,
'AddedTitle' => 'Widget A'
]);
Klaviyo::track(TrackEvent::make(
'Placed Order',
[
'unique_id' => '1234_WINNIEPOOH',
'value' => 9.99,
]
));
Klaviyo::track(TrackEvent::make(
'Placed Order',
[
'unique_id' => '1234_WINNIEPOOH',
'value' => 9.99,
],
[
'email' => '[email protected] ',
'first_name' => 'Foo',
'last_name' => 'Bar',
],
now()->addWeeks(-1)
));
use EonVisualMedia\LaravelKlaviyo\Klaviyo;
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Klaviyo::macro(
'fulfilled_order',
function (Transaction $transaction) {
Klaviyo::track(TrackEvent::make(
'Fulfilled Order',
$transaction->toKlaviyo(),
$transaction->user,
$transaction->created_at
));
}
);
}
Klaviyo::fulfilled_order($transaction);
Klaviyo::get('lists');
Klaviyo::post("profile-subscription-bulk-create-jobs", [
'data' => [
'type' => 'profile-subscription-bulk-create-job',
'attributes' => [
'profiles' => [
'data' => [
[
'type' => 'profile',
'attributes' => [
'email' => '[email protected] ',
'subscriptions' => [
'email' => [
'marketing' => [
'consent' => 'SUBSCRIBED'
]
],
]
]
]
]
]
],
'relationships' => [
'list' => [
'data' => [
'type' => 'list',
'id' => $list_id
]
]
]
]
]);
Klaviyo::delete("profile-subscription-bulk-delete-jobs", [
'data' => [
'type' => 'profile-subscription-bulk-delete-job',
'attributes' => [
'profiles' => [
'data' => [
[
'type' => 'profile',
'attributes' => [
'email' => '[email protected] ',
]
]
]
]
],
'relationships' => [
'list' => [
'data' => [
'type' => 'list',
'id' => $list_id
]
]
]
]
]);
bash
php artisan vendor:publish --provider="EonVisualMedia\LaravelKlaviyo\LaravelKlaviyoServiceProvider" --tag="tags-config"
// layout.blade.php
<html>
<body>
{{-- ... --}}
@