Evntaly
Visit Evntaly
  • 💙Welcome to Evntaly
  • What is Evntaly ?
  • Why Evntaly ?
  • Getting Started
  • 📦Supported Langauges
    • JavaScript
    • Ruby
    • Python
    • C#
    • Go
    • PHP
    • Web
    • cURL
      • Swift – Native HTTP
      • Flutter - Dart
      • Android - Kotlin
Powered by GitBook
On this page
  • Installation
  • Initialization
  • Tracking Events
  • User Identification
  • Enabling and Disabling Tracking
  • Best Practices
  • Troubleshooting
  • Support
  • ✨ Open-source community Achievements
  1. Supported Langauges

PHP

PHP SDK

PreviousGoNextWeb

Last updated 2 months ago

PHP client for interacting with the Evntaly event tracking platform. provides developers with a straightforward interface to initialize the SDK, track events, identify users, manage tracking states.

Installation

Install the Evntaly PHP SDK:

composer require evntaly/evntaly-php

Initialization

use Evntaly\EvntalySDK;

$developerSecret = 'YOUR_DEVELOPER_SECRET';
$projectToken = 'YOUR_PROJECT_TOKEN';

$sdk = new EvntalySDK($developerSecret, $projectToken);

Tracking Events

To track an event, use the track method with an associative array containing the event details.

$response = $sdk->track([
    "title" => "Payment Received",
    "description" => "User completed a purchase successfully",
    "message" => "Order #12345 confirmed for user.",
    "data" => [
        "user_id" => "usr_67890",
        "order_id" => "12345",
        "amount" => 99.99,
        "currency" => "USD",
        "payment_method" => "credit_card",
        "timestamp" => date('c'),
        "referrer" => "social_media",
        "email_verified" => true
    ],
    "tags" => ["purchase", "payment", "usd", "checkout-v2"],
    "notify" => true,
    "icon" => "💰",
    "apply_rule_only" => false,
    "user" => ["id" => "usr_0f6934fd-99c0-41ca-84f4"],
    "type" => "Transaction",
    "sessionID" => "sid_20750ebc-dabf-4fd4-9498",
    "feature" => "Checkout",
    "topic" => "@Sales"
]);

User Identification

To identify user details, use the identifyUser method. This helps link events to specific users and enriches your analytics.

$response = $sdk->identifyUser([
    "id" => "usr_0f6934fd-99c0-41ca-84f4",
    "email" => "john.doe@example.com",
    "full_name" => "Johnathan Doe",
    "organization" => "ExampleCorp Inc.",
    "data" => [
        "username" => "JohnD",
        "location" => "New York, USA",
        "plan_type" => "Premium",
        "signup_date" => "2024-01-15T10:00:00Z",
        "timezone" => "America/New_York"
    ]
]);

Enabling and Disabling Tracking

You can globally enable or disable event tracking for the current SDK instance. This might be useful for development/testing or respecting user consent.

// Disable tracking - subsequent track/identify calls will be ignored
$sdk->disableTracking();

// Re-enable tracking
$sdk->enableTracking();

Best Practices

  • Initialize early: Always initialize the SDK as early as possible.

  • Avoid sensitive data: Do not pass sensitive personal data directly to the SDK.

  • Monitor API limits: Regularly check API limits to avoid missing critical events.

Troubleshooting

  • Events not appearing: Check if the SDK is initialized correctly and the API tokens are valid.

  • Network errors: Ensure your network allows requests to https://evntaly.com.


Support

For additional help, contact support at support@evntaly.com.

✨ Open-source community Achievements

Initialize the SDK with your Developer Secret and Project Token - Check

Huge shout-out and thank you for who developed this SDK and it has been added, reviewed and tested by the Evntaly team.

📦
Here
Mohamed Kamal
GitHub - Evntaly/evntaly-php: Evntaly official library for your php projectsGitHub
Logo