Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

hostinger/Amplitude-PHP

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Amplitude PHP

Install

composer require hostinger/amplitude-php

How to use it

require_once 'vendor/autoload.php';

$apiKey = '123';
$amplitudeClient = new Amplitude\AmplitudeClient($apiKey);

$amplitudeEvent = new Amplitude\Message\Event();

// For user properties
$amplitudeEvent
    ->set('eventType', 'test.event')
    ->set('userId', 1)
    ->set('deviceId', 1)
    ->set('city_id', 1)
    ->set('country_id', 1);

// For event properties
$amplitudeEvent
    ->addToEventProperties('revenue', 1);

try {
    $response = $amplitudeClient->track($amplitudeEvent);
    print 'event tracked';
} catch (Exception $e) {
    print $e->getMessage();
}