This SDK allows developers to easily use the GetAmplify API with PHP. This repository contains the open source PHP SDK that allows you to utilize the above on your website.
You will need your API Key, API Secret and Project ID which you can find in your Settings.
For more information - please refer Docs
The GetAmplify PHP SDK provides a few simple ways to to send user events and set user properties.
Copy the SDK library file to a location within your web application's include path, and include it into any scripts that you wish to make API calls from.
include 'getamplify-sdk.php';
Before calling any of the common methods you must create an instance of amplify class with valid API key, secret and project ID:
$amplifyObject = new Amplify('API_Key','API_Secret','Project_Id');
A user is identified by its email address.
$amplifyObject->identify('Email_Address','Name');
Example
$amplifyObject->identify('[email protected]','Sandeep');
You can send an event performed by the user with this method. You can also pass properties along with this event. All the existing properties will be updated with the new values passed.
$amplifyObject->event(
'Email_Address',
array(
'Event_Name' => array(
'Property_Name'=>'Property_Value',
'Property2_Name'=>'Property2_Value'
)
)
);
Example
$amplifyObject->event(
'[email protected]',
array(
'addtocart' => array(
'product'=>'Samsung Note2',
'category'=>'Mobile',
'price'=>'456.78'
)
)
);
You can use update() method for updating user properties. Any old value of the property will be replaced with new value
$amplifyObject->update(
'[email protected]',
array(
'Property_Name'=>'Property_Value',
'Property2_Name'=>'Property2_Value'
)
);
Example
$amplifyObject->update(
'Email_Address',
array(
'country'=>'India',
'city'=>'Noida'
)
);
You can use add() method for updating user properties. Any old value of the property will be replaced with new value
$amplifyObject->add(
'Email_Address',
array(
'Property_Name'=>'Property_Value',
'Property2_Name'=>'Property2_Value'
)
);
Example
$amplifyObject->add(
'[email protected]',
array(
'comments'=>'1',
'shares'=>'1'
)
);
If you are running a B2C or e-commerce company, these functions are essential and shoudl be used.
A customer can have following action with products. Replace them from ‘action_names’
- viewed,
- purchased,
- wishlist,
- add_to_cart,
- reviewed,
- shared,
- completed
- removed_from_cart
Example
$amplifyObject->customerAction(
'[email protected]',
products => array(
'0' => array(
productId => 'xxx',
sku => 'xxx', //optional
productTitle => 'xxx', //optional
price => 'xxx',
specialPrice => 'xxx', //optional
status => 'xxx', //optional
stockAvailability => 'xxx',
pageURL => 'xxx', //optional
pictureURL => 'xxx', //optional
currency => 'xxx', //optional
orderId => 'xxx' //compulsory when action_name is purchased
),
'1' => array(
productId => 'xxx',
sku => 'xxx', //optional
productTitle => 'xxx', //optional
price => 'xxx',
specialPrice => 'xxx', //optional
status => 'xxx', //optional
stockAvailability => 'xxx',
pageURL => 'xxx', //optional
pictureURL => 'xxx', //optional
currency => 'xxx', //optional
orderId => 'xxx' //compulsory when action_name is purchased
)
)
);
You can send information about any new product through this function.
$amplifyObject->add(
'Email_Address',
array(
'Property_Name'=>'Property_Value',
'Property2_Name'=>'Property2_Value'
)
);
You can send information about any new through this function.
You can disable a product through this function. You can also change stock availability through this function itself.
$amplifyObject->add(
'Email_Address',
array(
'Property_Name'=>'Property_Value',
'Property2_Name'=>'Property2_Value'
)
);
Order is automatically created in customer action API. When a product is purchased, orderId is to be passed.
This function helps you updating orderStatus.
$amplifyObject->updateOrderStatus( orderId, orderStatus);
Yes, you can. Here's an example.
$amplifyObject->event(
'[email protected]',
array(
'addtocart' => false //property array should be false
)
);
Yes, you can. Here's an example.
$amplifyObject->event(
'[email protected]',
array(
'add_to_cart' => false, //Event1
'add_to_WishList' => false //Event2
)
);
No, you have to send an email address to identify him as an "Identified User". For any user, if email address is not known, it will be treated as Visitor. Though every visitor also had properties and events like Identified User.
You can use same functions without identifying the user. We create cookie for every visitor and store an unique alias id for that user. This cookie will be read and maintained by getamplify-sdk itself.
Here's and example. (Instead of email addess, blank value is passed) Example
$amplifyObject->event(
'',
array(
'addtocart' => array(
'product'=>'Samsung Note2',
'category'=>'Mobile',
'price'=>'456.78'
)
)
);
- PHP >= 5.2.0
- cURL
Request: Please let us know your feedback and comments. If you have any questions or need a further assistance please contact us at [email protected].