APIs & Integrations

drongo
Membro

Uncaught Error: Multiple lead flow scripts are trying to run on the current page

resolver

Hi there,

 

I'm trying to load tracking codes for Google Tag Manager, Facebook, etc after receiving user consent via Hubspot cookie consent banner.

 

According to this page https://legacydocs.hubspot.com/docs/methods/tracking_code_api/get_consent_status it's possible to do it in the following way:

 

 

var _hsp = window._hsp = window._hsp || [];
_hsp.push(['addPrivacyConsentListener', function(consent) {
    if (consent.allowed) {
    // Google Tag Manager tracking code
    (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
    new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
    j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
    })(window,document,'script','dataLayer','GTM-XXX');
    // Facebook tracking code.....
    }
}]);

 

 

I'm getting an error:

 

leadflows.js:12 Uncaught Error: Multiple lead flow scripts are trying to run on the current page. Only the first one will be executed. The rest are ignored. Read more at http://hubs.ly/H03mDPb0

 

Link above is dead. 

 

Could you please advise how to load multiple tracking codes?

0 Avaliação positiva
1 Solução aceita
drongo
Solução
Membro

Uncaught Error: Multiple lead flow scripts are trying to run on the current page

resolver

I resolved this issue by moving all tracking codes into GTM and load GTM code only on user consent.

Exibir solução no post original

4 Respostas 4
LFilip
Participante

Uncaught Error: Multiple lead flow scripts are trying to run on the current page

resolver

I'm having the exact same issue in an app that uses GTM and HS tracking code for chat integration.

0 Avaliação positiva
drongo
Solução
Membro

Uncaught Error: Multiple lead flow scripts are trying to run on the current page

resolver

I resolved this issue by moving all tracking codes into GTM and load GTM code only on user consent.

drongo
Membro

Uncaught Error: Multiple lead flow scripts are trying to run on the current page

resolver

Hi @dennisedson ,

 

thank you for your answer.

 

Yes, the issue is still there, I rolled back my changes for now since they were breaking the page. Any suggestions how to make it work?

0 Avaliação positiva
dennisedson
Equipe de Produto da HubSpot
Equipe de Produto da HubSpot

Uncaught Error: Multiple lead flow scripts are trying to run on the current page

resolver

Hi @drongo , are you still having this issue?  I see you have opened a ticket with support as well.  I looked at the referenced page from that ticket and I am not seeing this console error.  I have, however, brought up that the link in the error messaging is 404'ing

0 Avaliação positiva