Basic API Introduction (PHP)
|
Collect
1. User association
The purpose of user association is to uniquely identify users and improve the accuracy of user behavior analysis. At present, we provide simple user association and global user association to support different business scenarios.
2. User attribute
- For the difference between event properties and user properties, seedata model
- For naming restrictions on user attributes, seedata format
For simple user association and global user association scenarios, the Settings of user properties correspond to different interfaces. For details, see the following links based on service requirements.
3. Tracking event acquisition
After SDK initialization is complete, you can bury data through the following interface.
3.1. Trace event
For simple user association and global user association scenarios, tracking events correspond to different interfaces. Refer to the following links based on service requirements.
4. Item metadata report
In the Sensors recommendation project, customers need to report the item metadata to carry out the subsequent development and maintenance of the recommendation business. The Analytics SDK provides methods for setting and deleting item metadata.
item_id(item ID )and item_type (Type of item)together they form the unique identity of an item. All item family methods must be specified simultaneouslyitem ID andtype of item two parameters, to complete the operation of the item.
4.1. Set Item
Directly set an item. If it already exists, it will be overwritten. Except for the item ID and the item type, other item properties need to be defined in $properties.
For item properties, the constraints on attribute names and attribute values are the same as those of event properties. For more details, please refer to Data Format.
<?php # 例如 $item_type = 'fruit'; $item_id = 'ABCDEF123456789'; $sa->item_set($item_type, $item_id, array('apple' => 1)); ?>
4.2. Delete an item
If the item is not recommended and needs to be taken offline, deleting it will suffice. If it does not exist, ignore it.
Do not parse other item properties except for the item ID and the item type.
<?php #例如: $item_type = 'fruit'; $item_id = 'ABCDEF123456789'; $sa->item_delete($item_type, $item_id); ?>
4.3. Event properties
As mentioned earlier, custom event properties can be set for tracked events, such as the product ID and product category in the browse product event. In subsequent analysis work, event properties can be used as statistical filtering conditions and dimensions for multidimensional analysis. For event properties, there are some constraints in Sensors Analytics:
Event attributes are an array object. Each element in the array describes an attribute, with the key being the attribute name, which must be a string. In the array, the value of each element is the value of the attribute, which supports string, int, float, array, and DateTime.
For more constraints on event properties in Sensors Analytics, please refer to Data Format.
4.3.1. System predefined properties
In the example mentioned earlier, the properties in the event properties that start with '$' are system predefined properties. Filling in the corresponding '$'-prefixed property values in custom event properties can overwrite these predefined properties:
$ip - By filling in this property, Sensors Analytics will automatically parse the user's province and city information based on the IP address. The property value is of type string. $time - By filling in this property, Sensors Analytics will set the event time to the value of the property, which must be of type DateTime. Please note that Sensors Analytics by default filters out and ignores data that is more than 365 days before or 3 days after the current date. If you need to modify this setting, please contact us.
For more predefined properties in Sensors Analytics, please refer to Data Format in the section 'Predefined Properties'.
4.3.2. Common event properties
In particular, if an attribute of an event occurs in all events, you can use register_super_properties() set this property to the event public property. For example, set the application version of the server and the IP address of the equipment room as the public attributes of the event.
<?php $properties = array( # 服务器应用版本 'ServerVersion' => '1.2', # 服务器机房地址 'Location' => 'BeiJing', ); # 设置事件公共属性 $sa->register_super_properties($properties); ?>
After the public properties of the event are successfully set, use track() When tracing events, event public properties are added to each event.
Use clear_super_properties()will delete all the public properties of the event that have been set.
When the event public attribute conflicts with the Key of the event attribute, the event attribute has the highest priority and overrides the event public attribute.
Note: The content of this document is a technical document that provides details on how to use the Sensors product and does not include sales terms; the specific content of enterprise procurement products and technical services shall be subject to the commercial procurement contract.