Visitor Identification not Working

How should I integrate the Visitor Identification with Nuxt JS (vue2)?
i created a store that initializes the hsConversations

setHubspotAvailability({ commit }) {

window.hsConversationsSettings = {

loadImmediately: false,

inlineEmbedSelector: “#hubspot-modal”,

disableAttachment: false,

};

if (window.HubSpotConversations) {

commit(“SET_HUBSPOT_CHAT_AVAILABILITY”, true);

window.HubSpotConversations.widget.load();

window.HubSpotConversations.widget.open();

} else {

window.hsConversationsOnReady = [

() => {

commit(“SET_HUBSPOT_CHAT_AVAILABILITY”, true);

window.HubSpotConversations.widget.load();

window.HubSpotConversations.widget.open();

},

];

}

},

i can easily get the token and email for the hsConversationSettings object to set i just dont know where should it be placed to make it work.

where should i place the setting of the hsConversationSettings object with email and token?

Hello @LManansala2
The hsConversationSettings object should be placed in the store/modules/hubspot/index.js file. Here is an example of how to do it.

import { defineStore } from 'vuex';
import { hsConversationsSettings } from 'hubspot-conversations';

export default defineStore({
 state: {
 hubspotChatAvailability: false,
 },
 mutations: {
 SET_HUBSPOT_CHAT_AVAILABILITY(state, availability) {
 state.hubspotChatAvailability = availability;
 },
 },
 actions: {
 setHubspotAvailability({ commit }) {
 const { token, email } = getHubspotCredentials();
 window.hsConversationsSettings = {
 token,
 email,
 loadImmediately: false,
 inlineEmbedSelector: '#hubspot-modal',
 disableAttachment: false,
 };
 commit('SET_HUBSPOT_CHAT_AVAILABILITY', true);
 },
 },
});

First importing the hsConversationSettings object from the hubspot-conversations library. Then, we are defining a store object that has a state property with a hubspotChatAvailability property. This property will be used to store whether or not the HubSpot chat widget is available.

Next, we are defining a mutation called SET_HUBSPOT_CHAT_AVAILABILITY. This mutation will be used to update the hubspotChatAvailability property in the state object.

Finally, we are defining an action called setHubspotAvailability. This action will be used to set the hsConversationSettings object. The hsConversationSettings object contains the token and email that are needed to identify the visitor.

Once you have added this code to your store, you can then call the setHubspotAvailability action to initialize the HubSpot chat widget. For example, you could call the setHubspotAvailability action in the created hook of your main component.

Here is an example of how to call the setHubspotAvailability action in the created hook

import { mapGetters } from 'vuex';

export default {
 name: 'MyComponent',
 created() {
 this.$store.dispatch('setHubspotAvailability');
 },
 ...
};

Once you have called the setHubspotAvailability action, the HubSpot chat widget should be initialized and should be available to visitors.