qubit / segments
This package is abandoned and no longer maintained.
No replacement package was suggested.
Library for getting a visitors current segments
v1.1.0
2016-11-02 16:24 UTC
Requires
- php: >=5.5
- guzzlehttp/guzzle: ^6.2
Requires (Dev)
- ext-curl: *
- phpunit/phpunit: ^4.0
- psr/log: ^1.0
This package is not auto-updated.
Last update: 2020-08-25 23:39:42 UTC
README
Usage
use QubitSegments; $trackingId = "retail_demo_union_fashion"; // This is the tracking id from your QProtocol events. Either ask your Qubit contact for details or look at the `meta.trackingId` value in your QP events. $segmentId = "SG-4286-f06a1268" $segments = new Segments($trackingId); $visitorId = QubitSegments\getVisitorIdFromCookie($_COOKIE["qb_permanent"]); $memberships = $segments->getSegmentMembershipsForVisitor($visitorId); if ($memberships->isMemberOf($segmentId)) { print "Visitor $visitorId is in segment $segmentId"; } // if you want to get segments asynchronously $request = $segments->getSegmentMembershipsForVisitor($visitorId) $request->then(function ($memberships) { if ($memberships->isMemberOf($segmentId)) { print "Visitor $visitorId is in segment $segmentId"; } })
Run make example
to see a demo of it working.
Installation
The recommended way to install Qubit Segments is through Composer.
curl -sS https://getcomposer.org/installer | php
Next, run the Composer command to install the latest stable version of Qubit Segments:
php composer.phar require qubit/segments
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
You can then later update using composer:
php composer.phar update