Javascript Event Tracking

Track events that happen on your app's frontend or on your site using the Encharge Javascript tracking.

Make sure you have installed the Encharge JS snippet by following the instructions in the app.

If there is a chance that the Encharge JS snippet will be run after code that calls it, add the following line of code before calling any of its methods:

if (!window.EncTracking) window.EncTracking={queue:[],track:function(e){this.queue.push({type:"track",props:e})},identify:function(e){this.queue.push({type:"identify",props:e})}};


The identify method can be used to:

  • Uniquely identify the current person.

  • Enrich his or her profile with additional traits

We recommend calling identify on the following events:

  • After a user registers

  • After a user logs in

  • When a user updates their info (for example changes his plan or updates his address)

email: "[email protected]",
userId: "123"


Use track method to record actions that users take in your app.

Please note that pageviews are tracked automatically, so you don't need to emit events for them.

The track method uses the same request body as our Ingest API.

For example, to log that one of your users sent a message, you'd use the following:

// Name of this event
"name": "Sent Message",
// Properties of this event (optional)
"properties": {
"numberOfRecipients": 2
// Additional fields for the current user performing the event (optional)
"user": {
"email": "[email protected]",
// Any other fields will be added to this person.
"name": "Michael Scott",

You can omit calling the identify method by sending the user traits in the user property of the track method (see the example above).