actengage/laravel-passendo

There is no license information available for the latest version (v0.5.0) of this package.

A Passendo package for Laravel.

v0.5.0 2023-07-11 16:29 UTC

This package is auto-updated.

Last update: 2024-04-11 18:04:04 UTC


README

PHP Composer

This is a Laravel package that makes tracking Passendo clicks easy. This package includes migrations, models, jobs, and the various handles to retry failed attempts.

composer require actengage/laravel-passendo

Basic Usage

The easiest way to use this package is to attach the trait to an Eloquent model. You must implement a cpa() and tid() method to fetch the CPA's and tracking ID's (respectively).

use Actengage\LaravelPassendo\Contracts\TrackPassendoClicks as TrackPassendoClicksInterface;
use Actengage\LaravelPassendo\TrackPassendoClicks;
use Illuminate\Database\Eloquent\Model;

class User extends Model implements TrackPassendoClicksInterface {

    use Optionable, TrackPassendoClicks;

    public function cpa(): float
    {
        return $this->options->get('cpa');
    }

    public function tid(): string
    {
        return $this->tracking_id;
    }

    public function shouldTrackPassendoClicks(): bool
    {
        return true;
    }
}

Use the Click model.

You can also create \Actengage\LaravelPassendo\Click models just as any other Eloquent model. Give the tracking_id and cpa attributes a value, and the jobs will automatically dispatch.

use Actengage\LaravelPassendo\Click;

// Manually create a click model
$click = Click::create([
    'tracking_id' => 'test1',
    'cpa' => 1
]);

Polymorphic Relationships.

You may optionally associate a polymorphic relationship, which associates the click to a parent model.

$user = User::firstOrCreate([
    'email' => 'test@test.com'
]);

$click->parent()->associate($user);

Using the TrackPassendoClicks trait.

If you are implementing the \Actengage\LaravelPassendo\TrackPassendoClicks trait, then you can use the clicks() helper to create and associate a model at once.

User::create()->clicks()->create([
    'tracking_id' => 'test2',
    'cpa' => 1
]);