Custom Event Tracking

This method is used to track custom events which are defined by the client, to which you can analyze users usage pattern of the product. Each event must have a name and a set of attributes describing more about the event in detail. You can send only event name also if you don't have any attributes by nil/null in and Payload parameter.

// Example
NSMutableDictionary *payloadDictionary = [NSMutableDictionary new];
[payloadDictionary setObject:@"1329" forKey:@"product_id"];
[payloadDictionary setObject:@"T-shirt" forKey:@"product_name"];
[payloadDictionary setObject:@"Polo" forKey:@"brand"];

[[Smartech sharedInstance] trackEvent:@"Product Viewed" andPayload:payloadDictionary];
// Example
let payloadDictionary = [
                "product_id" : "1329",
                "product_name" : "T-shirt",
                "brand" : "Polo"]

Smartech.sharedInstance().trackEvent("Product Viewed", andPayload:payloadDictionary)
SmartechSDK.trackEvent("EVENT_NAME", "PAYLOAD_STRING");

// Sample code for reference purpose only
const payloadata = {
    name: "Galaxy",
    description: "20gram bars",
    payload_id: "1",
    event_id:21
};
SmartechSDK.trackEvent("Page Browse", payloadata);

📘

Note:

  1. Smartech will automatically discover new activity by activity name along with payload parameters and data types.
  2. Smartech supports the following data types - String, Integer, Float, Date, Array, Dictionary.
  3. Please provide the value of the date in YYYY-MM-dd HH:mm:ss format.
  4. All the payload keys must be in lower cases.
  5. For revenue and conversion tracking, the data type should be Integer or Float.

Please do note that you cannot pass custom payload parameters for system events that Netcore SDK tracks automatically - e.g. App Launch, First App Launch, App Reinstalled, App Updated

Complex event attributes

You can send complex event attributes with the combination of NSArray and NSDictionary data types. This complex event attributes will be auto-discovered on the Netcore CE panel and can be used to send campaigns.

NSMutableDictionary *payloadDictWithArray = [NSMutableDictionary new];
[payloadDictWithArray setObject:@ 36899.74 forKey:@"amount"];
[payloadDictWithArray setObject:@"UATX123454" forKey:@"txid"];
[payloadDictWithArray setObject:@"INR" forKey:@"currency"];
[payloadDictWithArray setObject:@"2017-01-09T00:00:00.000Z" forKey:@"delivery_date"];

NSMutableDictionary *item1Dictionary = [NSMutableDictionary new];
[item1Dictionary setObject:@"ACNF2425FDRWQRHW" forKey:@"sku_code"];
[item1Dictionary setObject:@"13456" forKey:@"prid"];
[item1Dictionary setObject:@"Voltas" forKey:@"brand"];
[item1Dictionary setObject:@"1.5 Ton 3 Star BEE Rating 2018 Inverter AC" forKey:@"prname"];
[item1Dictionary setObject:@ 35999.75 forKey:@"price"];
[item1Dictionary setObject:@ 1 forKey:@"prqt"];
        
NSMutableDictionary *item2Dictionary = [NSMutableDictionary new];
[item2Dictionary setObject:@"TSHFFZTHF96HSW2X" forKey:@"sku_code"];
[item2Dictionary setObject:@"Men V-neck Multicolor T-Shirt" forKey:@"prname"];
[item2Dictionary setObject:@"US POLO ASSN" forKey:@"brand"];
[item2Dictionary setObject:@ 899.99 forKey:@"price"];
[item2Dictionary setObject:@ 2 forKey:@"prqt"];
        
NSArray *itemsArray = [[NSArray alloc] initWithObjects:item1Dictionary, item2Dictionary,nil];
[payloadDictWithArray setObject:itemsArray forKey:@"items"];

[[Smartech sharedInstance] trackEvent:@"Add to cart" andPayload:payloadDictWithArray];
let item1Dictionary = ["sku_code" : "ACNF2425FDRWQRHW",
                               "prid" : "13456",
                               "brand" : "Voltas",
                               "prname" : "1.5 Ton 3 Star BEE Rating 2018 Inverter AC",
                               "price" : 35999.75,
                               "prqt" : 1]

let item2Dictionary = ["sku_code" : "TSHFFZTHF96HSW2X",
                       "prname" : "Men V-neck Multicolor T-Shirt",
                       "brand" : "US POLO ASSN",
                       "price" : 899.99,
                       "prqt" : 2]
        
let payloadDictWithArray = ["amount" : 36899.74,
                            "txid" : "UATX123454",
                            "currency" : "INR",
                            "delivery_date" : "2017-01-09T00:00:00.000Z",
                            "items" : [item1Dictionary, item2Dictionary]] as [String : Any]

Smartech.sharedInstance().trackEvent("Add to cart", andPayload:payloadDictWithArray)

📘

Note

You can send maximum of 100 unique custom events names. Any additional events exceeding this limit will be dropped. You can reach out to your account manager if you want to send more events.