APIs & Integrations

hiltonrrn
Participant

Custom javascript snippet not load on a domain pages

Hello all!

 

I'm trying to load a custom javascript code in Hubspot, following Settings -> Sites -> Pages (all domains default settings), at the HTML footer section.

 

But the code is not loaded when the user access the page. When I put the code at a simmilar option, in a specific page, the code loads properly.

 

I have already tried clean the browser cache, but the issue remains. 

 

Can someone help with that?

 

Thanks,

0 Upvotes
3 Replies 3
WendyGoh
HubSpot Employee
HubSpot Employee

Custom javascript snippet not load on a domain pages

Hi @hiltonrrn,

 

To further troubleshoot this, could you share with me:

 

1. Your portal ID

2. The code

 

If it's more comfortable for you, you can share via DM.

0 Upvotes
hiltonrrn
Participant

Custom javascript snippet not load on a domain pages

Hello @WendyGoh,

 

1. The portal ID: 5437378

 

2 . The code:

<script type='text/javascript'>
  var utm;
  utm = setTimeout(function () {
    const params = new URLSearchParams(window.location.search);
    const utm_params = [];
    params.forEach(function(value, key) {
		utm_params.push(key+'='+value)
    })
    utm_search = utm_params.join('&');
    if (!!utm_search) {
        document.querySelectorAll('a[href]').forEach(function(ele, idx) {
            if (ele.href.indexOf(utm_search) > -1) {
              clearTimeout(utm);
            }
            ele.href = ele.href + (ele.href.indexOf('?') === -1 ? '?' : '&') + utm_search;
        });
    }
  }, 3000);
</script>

 

Thanks,

0 Upvotes
WendyGoh
HubSpot Employee
HubSpot Employee

Custom javascript snippet not load on a domain pages

Hi @hiltonrrn,

 

When I place the javascript code that you shared with me on Settings > Website > Pages > Default settings for all domains > Site header HTML > Below the Facebook pixel code, I was able to see that it load just fine on one of your website page (view page source of the page > note that the code is located just before the body closing tag)

 

Could you try placing the code as where I did and see if it's showing up on your website pages?

0 Upvotes