@Irsan Mardiansyah Can you share more about your website? Is it a one page web app or standard website? On a single page webapp you’ll need a different code for Intercom and/or are you not using the Intercom JS and trying to custom code something for tracking here?
@Nathan Sudds It’s standard website with more than one page, I use intercom JS to trigger survey by code and want to track the users activity whenever the user fill the survey. I use this reference https://www.intercom.com/help/en/articles/175-set-up-event-tracking-in-intercom#h_7816b125af and still not working.
Hey @Irsan Mardiansyah, Emily here from Support Engineering at Intercom
To track user activity and set custom attributes in Intercom using JavaScript, you should use the Intercom('update', user) method to update user information and the Intercom('trackEvent', eventName) method to track events. For setting a custom attribute such as is_admin, you would include it within the user object like so:
Intercom('update', {
custom_attributes: {
is_admin: true
}
});
This will update the user's profile with the custom attribute is_admin set to true. If the attribute is_admin is not recognized by Intercom, it should be created automatically upon updating the user with this attribute.
To track an event, such as a user filling out a survey, you would use the trackEvent command. Here's an example of how to track a button click event:
window.intercom('trackEvent', 'survey-completed');
This will send an event to Intercom indicating that the survey was completed. Make sure that the event name matches the one you have set up in your Intercom settings for triggering surveys.
If you're following the steps from the Intercom help article and it's still not working, ensure that the Intercom JavaScript API is correctly installed and initialized on your website. The event tracking should be set up as described in the documentation, and you can include metadata with the event for more detailed tracking if needed.