Hackle SDK provides the ability to track and send user events to Hackle.
Data on user events is necessary for measuring the results of the experiment based on the metrics initially set for meaningful user behavior analysis.
User events can be tracked and sent by passing the event key and user identifier value to the
track() method. In cases where you would also like to know the value, you can put a numeric value in
value and send it together as user events.
valuecan only be in the form of numerical values.
Suppose you have defined an event key called 'purchase' to collect an event when the user presses the purchase button. You may also want to simultaneously collect the exact purchase amount as well. In this case, you can receive the purchase amount together with
<?php require 'vendor/autoload.php'; $client = \Hackle\HackleClients::create("YOUR_SDK_KEY"); // Sends an event called “purchase” that is triggered by a user with an identifier of “ae2182e0”. // Send the event key and numeric value together $user = \Hackle\Common\HackleUser::of("ae2182e0"); $event = \Hackle\Common\HackleEvent::builder("purchase") ->value(13200) // Enter the numeric value to be collected along with the event key in "value" ->property("pay_method", "CARD") ->property("discount_amount", 800) ->property("is_discount", true) ->build(); $client->track($event, $user); ?>
From the above examples, example 1 is showing a case where only the event key is being sent for the purchase action, while example 2 shows a case where both the purchase event key and the purchase amount is being collected by adding in the 'value' to collect information on the exact purchase amount.
Hackle SDK supports adding properties to event objects.
- Properties must be sent as a pair with a key and value.
- The maximum number of additional properties that can be added to a event object is 64.
- It is recommended to create property names like regular variable names, making them easy to identify.
- There is a limit of 64 characters for the property name.
- The property names are case-insensitive. For example, "amount" and "AMOUNT" are considered the same key.
- Property values can be of boolean, string, float, or int types.
- If the value is a string type, there is a limit of 64 characters for the string length.
Updated 3 months ago