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.