PHP Client

Integrate with your PHP project in minutes

Installation

Using PHP you can easily add UserLog to your project by installing the package from composer:

composer require userlog/php

Initialize Client

Now you can initialize the UserLog client like this:

use UserLog\PHP\Client;

$userlog = new Client('<API_KEY>', '<PROJECT_NAME>');

Usage

Now you can use the UserLog client like this:

// The channel name, event name and user_id are the only required parameters.
$userlog->log('subscriptions', 'User subscribed!', 'user@example.com');

// Other parameters can be added when needed.
$userlog->log(
    channel: 'subscriptions',
    event: 'User subscribed!',
    user_id: 'user@example.com',
    description: 'A new user subscribed.',
    icon: '👍🏼',
    notify: false,
    tags: [
        'payment-method' => 'card',
        'plan' => 'monthly',
    ],
);

Tipps

All logged events will link to the user who set off the event. This will help you understand user behavior. You can track events such as order made, item added to cart, new subscription created, or feedback submitted.