cachethq/segment

Segment.com wrapper written for Laravel

Downloads

16860

Stars

15

Version

2.1.2

This package has been archived

Laravel Segment

Segment.com wrapper for Laravel 5.

THIS PACKAGE IS NOW DEPRECATED. PLEASE LOOK AT ALTTHREE/SEGMENT

Installation

Add the following to your composer.json file.

"require": {
    "cachethq/segment": "~2.1"
}

Get the package installed.

$ composer update

Add the service provider to app.php

'providers' => [
    // ...
    'CachetHQ\Segment\SegmentServiceProvider',
],

If you want to use the Facade, also add the alias:

'aliases' => [
    // ...
    'Segment'  => 'CachetHQ\Segment\Facades\Segment',
],

Install the configuration file.

$ php artisan vendor:publish

Update the new configuration file with your write_key as provided by Segment.com

Using Laravel Segment

Once you've set your write_key value in the configuration, you're ready to go! For the most part you can follow Segments own instructions however, you'll want to replace the Analytics classname with Segment - plus, you don't need to call class_alias.

Identify the user

Segment::identify([
    "userId" => "12345abcde",
    "traits" => [
        "name"  => "James Brooks",
        "email" => "[email protected]",
    ]
]);

Track actions

Segment::track([
    "userId"     => "12345abcde",
    "event"      => "Did something",
    "properties" => [
        "was_awesome" => true,
    ]
]);

License

Laravel Segment is licensed under The MIT License (MIT).

GrahamDeprecated

Author

GrahamDeprecated