Using HS tracking script with Conversation API

Question: Does the HS tracking code script (<script type=“text/javascript” id=“hs-script-loader” async defer src="js.hs-scripts.com/XXXXXXX.js "></script>) provides the same functions as the HS Conversation API scripts seend below:

<script type="text/javascript">
 function onConversationsAPIReady() {
 //console.log(`HubSpot Conversations API: ${window.HubSpotConversations}`);
 window.HubSpotConversations.on( 'conversationStarted', function(payload) {
 //console.log("HubSpot Conversation Started");
 window.dataLayer.push({
 'event': 'HubSpot',
 'hs-action': 'conversation-started',
 'hs-conversation-id': payload.conversation.conversationId
 })
 });
 //Listens for the conversation window to be closed
 window.HubSpotConversations.on( 'conversationClosed', function(payload) {
 //console.log("HubSpot Conversation Closed");
 //This means the conversation is fully closed. Minimizing doesn't count.
 window.dataLayer.push({
 'event': 'HubSpot',
 'hs-action': 'conversation-closed',
 'hs-conversation-id': payload.conversation.conversationId
 })
 });

 //Listens for a change in the number of unread messages
 window.HubSpotConversations.on( 'unreadConversationCountChanged', function(payload) {
 //console.log("HubSpot Unread Messages Count Change");
 window.dataLayer.push({
 'event': 'HubSpot',
 'hs-action': 'unread-message-count-change',
 'hs-conversation-id': payload.unreadCount
 })
 });
 }
 /*
 If external API methods are already available, use them.
 */
 if (window.HubSpotConversations) {
 //console.log('The api is ready already');
 onConversationsAPIReady();
 } else {
 /*
 Otherwise, callbacks can be added to the hsConversationsOnReady on the window object.
 These callbacks will be called once the external API has been initialized.
 */
 window.hsConversationsOnReady = [onConversationsAPIReady];
 }
 </script>

Hi, @STapp :waving_hand: Thanks for the great question. It’s definitely worth calling out.

To directly answer your question:

No, the HS tracking code script does not provide the same functionalities as the HS Conversation API script.

  • The HS tracking code script is more general and focuses on broader website analytics and behaviors
  • The HS Conversation API script is specific to chat and conversation events

If you are planning to utilize both tracking functionalities and conversation events, you’ll likely want to include both scripts on your website.

Best,

Jaycee

Thanks for the reply, @Jaycee_Lewis, one more followup question:
Does the ‘HubSpot All-In-One Marketing - Forms, Popups, Live Chat’ Wordpress plugin perform the same functions as both of those other scripts?