Skip to main content

Track custom events


When working with custom events, please make sure the event is also registered in the talon one application. By default tracking of events is only possible from the middleware. However, by exposing a GraphQl mutation we can easily port this behaviour to the client.

Functionally event tracking

talononeDataSource.trackProfileEvent(customerId, type, attributes); // Track customer events on talonOne CustomerProfile;
talononeDataSource.trackSessionEvent(customerId, cartId, type, attributes); // Track cart events on talonOne CustomerSession;

Proxy client side event tracking trough GraphQl

In the example below we leverage the talononeDataSource.trackSessionEvent in a mutation resolver. In his way we can easily fire custom events from the client.

gqlResolvers() {
Mutation: {
trackCategoryView: (root, { input }, context): Promise<boolean> => {
const { customerId, cartId } = context.container.get<ShopHttpSession>('ShopHttpSession');

return context.dataSources.talonone.trackSessionEvent(customerId, cartId, 'CategoryViewed', {

Don't forget to add the trackCategoryView mutation to the GraphQl schema.

Now we got everything set up we can call and test our mutation;

mutation TrackCategoryView($input: TrackCategoryViewInput!) {
trackCategoryView(input: $input)
"input": {
"name": "category-1"