Skip to content

Azure Application Insights – trackEvent with custom properties in Javascript

We are using the client-side javascript SDK (via the snippet-based integration) for Application Insights to track custom events


How can I add custom properties to this? Something like this?!

appInsights.trackEvent({name:"WinGame", customProperties:{gameName:"Game 1", player:"my player 1"}});


As seen on the JS Azure appinsights github page:

Custom properties can be included in your telemetry through the properties named argument. This can be done with any of the Track APIs.

    name: 'some event',  
    properties: { // accepts any type
       prop1: 'string',
       prop2: 123.45,
       prop3: { nested: 'objects are okay too' }