Spec: Track Event

trackEvent method is used to record the activities of an user on your Website / Application along with certain properties that explains that activity.

trackEvent method has the following fields:

FIELD TYPE DESCRIPTION
userID String This is the unique identification that you can give to your User. Usually Database ID will be used as userID. This field is not required in case of Javascript Library. Refer userID section of identify spec to know more.
eventName
(Required)
String The name of the event you are tracking. Refer eventName section to know more.
eventProperties
(Optional)
Object This contains the additional properties you know about the event. Refer eventProperties section to know more.
successCallback (Optional) Function A function that is executed after receiving the success response for trackEvent call. This callback is available only in Javascript Library.
failureCallback (Optional) Function A function that is executed incase of failed trackEvent calls. This callback is available only in Javascript Library.
Event Name

This should be the name of the activity user performed such as "Registered for Newsletter", "Added an item to Cart".

You should give a proper name for an event, which clearly should explain about the activity a user has performed and should be easily perceivable.

Event Properties

These are the additional properties that you can attach to an Event. You can send any number of properties for an event.

Events such as "Added an item to Cart" will give more context, if you know category of the product or name of the product.

Example trackEvent call of Javascript library along with successCallback and failureCallback:

1
2
3
4
5
6
7
8
9
10
11
12
13
var eventName = 'Subscribed Newsletter'; var eventProperties = { 'title': 'Subscribed Newsletter', 'email': 'john.doe@example.com' }; freshsales.trackEvent(eventName, eventProperties, function(response){ console.log("Succeeded to push to Freshsales!!", response); }, function(response){ console.log("Failed to push to Freshsales!!", response); });
EXPAND ↓

Example trackEvent call of Ruby library:

1
2
3
4
5
6
7
8
9
userId = '123456' eventName = 'Inviting Users' eventProperties = { 'user email' => 'user@abc.com' } FreshsalesAnalytics::trackEvent(userId, eventName, eventProperties)
EXPAND ↓
Help and Support
Send us a message
Chat with us