PHP code example of ideacrafters / laravel-dittofeed
1. Go to this page and download the library: Download ideacrafters/laravel-dittofeed 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/ */
ideacrafters / laravel-dittofeed example snippets
use Ideacrafters\Dittofeed\Facades\Dittofeed;
// Identify a user
Dittofeed::identify('user-123', [
'email' => '[email protected]',
'name' => 'John Doe',
'plan' => 'premium',
]);
// Track an event
Dittofeed::track('Purchase Complete', [
'amount' => 99.99,
'currency' => 'USD',
'product' => 'Premium Plan',
], 'user-123');
// Track a page view
Dittofeed::page('Pricing Page', [
'url' => 'https://example.com/pricing',
'title' => 'Pricing - Example App',
], 'user-123');
// If user is authenticated, userId is resolved automatically
Dittofeed::track('Button Clicked', [
'button' => 'Sign Up',
]);
use Dittofeed\Laravel\Traits\TracksDittofeedEvents;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
use Ideacrafters\Dittofeed\Traits\TracksDittofeedEvents;
use TracksDittofeedEvents;
// Define which model events to track
protected $dittofeedEvents = [
'created' => 'User Registered',
'updated' => 'Profile Updated',
'deleted' => 'Account Deleted',
];
// Define which attributes to send as traits
protected $dittofeedTraits = ['email', 'name', 'plan'];
}