PHP code example of temperbit / larahog
1. Go to this page and download the library: Download temperbit/larahog 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/ */
temperbit / larahog example snippets
// config/larahog.php
'connections' => [
'default' => [
'project_token' => env('POSTHOG_PROJECT_TOKEN'),
// ...
],
'marketing' => [
'project_token' => env('POSTHOG_MARKETING_TOKEN'),
// ...
],
],
LaraHog::connection('marketing')->capture('user-123', 'campaign_clicked');
use TemperBit\LaraHog\Facades\LaraHog;
// Basic event
LaraHog::capture('user-123', 'page_viewed');
// With properties
LaraHog::capture('user-123', 'purchase_completed', [
'amount' => 49.99,
'currency' => 'USD',
]);
// With group association
LaraHog::capture('user-123', 'report_exported', [], [
'company' => 'company-456',
]);
// Anonymous event
LaraHog::capture(null, 'landing_page_viewed');
LaraHog::identify('user-123', [
'name' => 'Jane Doe',
'email' => '[email protected] ',
'plan' => 'enterprise',
]);
LaraHog::alias('user-123', 'anonymous-session-abc');
LaraHog::groupIdentify('company', 'company-456', [
'name' => 'Acme Corp',
'industry' => 'SaaS',
]);
LaraHog::flush(); // Flush the default connection
LaraHog::flushAll(); // Flush all connections
if (LaraHog::isEnabled()) {
// ...
}
bash
php artisan vendor:publish --tag="larahog-config"
bash
php artisan larahog:status
php artisan larahog:status --connection=marketing