1. User Association

User association is used to uniquely identify users and improve the accuracy of user behavior analysis. Currently, Sensors Analytics provides simple user association to support business scenarios.

2. User Attributes

  • For the difference between event attributes and user attributes, please refer to the data model.
  • For the naming constraints of user attributes, please refer to the data format.

For specific information based on business requirements, please refer to the following links.

3. Event Tracking

After the SDK is initialized, you can use the following interfaces for event tracking.

3.1. Track an Event

For specific information based on business requirements, please refer to the following links.

3.2. Item Metadata Reporting

In the Sensors Analytics recommendation project, customers need to report item metadata to develop and maintain subsequent recommendation business. The Sensors Analytics SDK provides methods to set and delete item metadata.

The item_id (item ID) and item_type (item type) together constitute a unique identifier for an item. All item-related methods must specify both the item ID and the item type to complete operations on the item.

3.2.1. Set an Item

To directly set an item, overwrite if it already exists. In addition to the item ID and item type, other item attributes must be defined in $properties.

In item attributes, the naming constraints and value constraints are the same as event attributes. For detailed explanations, please refer to the data format.

// 示例 // 商品 Type const itemType = 'book' // 商品 ID const itemId = '0321714113' // 商品信息 const properties = { name: 'C++ Primer', price: 31.54, } // 添加商品 sa.itemSet(itemType, itemId, properties)
CODE

3.2.2. Delete an item

If the item cannot be recommended and needs to go offline, just delete it, or ignore it if it does not exist.

Other than the item ID and type of the item, no other item attributes are parsed.

// 示例 // 商品 Type const itemType = 'book' // 商品 ID const itemId = '0321714113' // 删除商品 sa.itemDelete(itemType, itemId)// 商品 Type
CODE

4. Event attribute

As in the previous example, you can set custom event attributes for tracking events. For example, in browsing product events, information such as product ID and product classification can be used as event attributes. In the subsequent analysis work, the event attribute can be used as a statistical filter condition or as a dimension for multidimensional analysis. For event attributes, there are some constraints on divine analysis:

  • The event attribute is map[string]interface{} object
  • Inmap , each element in the command describes an attribute. Key is the attribute name and must be string type
  • Inmap , the value of each element is the value of the attribute, supported stringintfloat64[]stringtime.Time

For more constraints on event attributes in Sensors analytics, see data format

4.1. System preset attribute

For example, the attributes starting with "$" in the event attribute are system preset attributes. You can override these preset attributes by filling in the corresponding attribute value starting with "$" in the user-defined event attribute:

  • $ip - If you enter this attribute, the analysis will automatically resolve the user's province and city information based on the IP address. The value of this attribute isstring type;
  • $time - Fill in the property, and Divine Analysis sets the event time to the property value, which is of type int64. Please note that by default, the data before 365 days or after 3 days will be filtered out. Please contact us if you need to change it.

For more preset properties, seedata format In the "Preset Properties" section.

4.2. Event common attribute

In particular, if an attribute of an event occurs in all events, it can be passed RegisterSuperProperties() Set this property to the event public property. For example, set the application version of the server and the equipment room address as the public attributes of the event.


	superProperty := map[string]interface{}{ 		"ServerVersion": "1.2", 		"Location": "BeiJing", 	} 	sa.RegisterSuperProperties(superProperty)
CODE

Use ClearSuperProperties() will delete all the public properties of the event that have been set. Use UnregisterSuperProperty() will delete the public properties of the specified Key.

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.