Blogs not working when installing third party code

Hi Sitejetters,

I’ve installed the Vbout code in the body section as I’m using it for email subscriptions. But seems to be a conflict, when I put the custom HTML code, the blog posts are not opening and it gives a 404 error when clicking on blog-post. Basically, the click does not redirect to the complete URL, instead, it just picks domain.com/blog-post and doesn’t pick slug for the blog item. How can I resolve this issue without removing the code?

TIA

Hey Praveen, could you also post the code here? Some of our Sitejet-Magicians might be able to help out better then :slight_smile:

Thanks for the suggestion @Andre.

Here’s the code -

<script type="text/javascript">
/* embed code starts */
var _vbset = _vbset || [];
_vbset.push(['_account', 'VBT-11608-7375']);
_vbset.push(['_domain', 'https://weblyr.com']);

(function() {
	var vbt = document.createElement('script'); vbt.type = 'text/javascript'; vbt.async = true; 
	vbt.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'www.vbt.io/tracker?_account='+_vbset[0][1]+'&_domain='+_vbset[1][1];var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(vbt, s);
})();
/* embed code ends */
</script>

Commenting to bring up my post. Still looking for help with this.

@Lucian_Dinu @zachary @Kamil - Any ideas?

Hi! Can you explain where did you added this VBOUT code?

  1. Did you use the HTML element?
  2. Did you added the code in the Code Management editor Code → HTML after the {{content}} tag ?

Where the clicking issue is happening in the Website Editor (in preview mode) or on the published website?

Initially I added the code using html element in the footer section. When it started causing problems, I pasted it in body section in html editor. But even then it causes the same problem.

Hi! I see there is an issue with the way VBOUT tracks the clicks…
It looks at the data-href attributes, and in Sitejet in the Collection container this attribute is set to the “/item” url …

I think there are 2 ways of fixing this:

  • contact VBOUT to update the library to make it compatible with Sitejet (or with any CMS that uses the data-href attribute)
  • use the dirty workaround below

Workaround (add this code after your VBOUT code):

<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function(e){
    setTimeout(function(){
        document.querySelectorAll('a[data-href]').forEach(function(aLink){
           aLink.removeAttribute('data-href');
        });
    }, 2500);

})
</script>

The code above will remove all data-href attributes from the links.
Right now is doing this after 2.5s , after the page is loaded.
Ideally, it would be great to have an event from Sitejet to know when the Collection container has finished loading the data.

Hope this helps.

4 Likes

Thank you for your help on this @Lucian_Dinu . I like the new word “bellow” by the way. “Bello” is a German fun word for dog, haha :slight_smile:

3 Likes

Dang, beat me to it! :smiley:

1 Like

Thank you so much @Lucian_Dinu. I will try the dirty approach first to be able to make it work immediately and will also contact Vbout support to ask what they can do about it. You are a real genious.

1 Like

I tried adding this code but still, the pages show a 404 errors and are not getting redirected to the blog-post slug. please help me out.

Hi! I’ve re-tested this solution and is not working properly… removing the data-href attribute has an impact on collections with multiple pages.

I can’t find a way to make it work.
The only thing that I see is to contact VBOUT and see if they can update the lib.

1 Like

Hi again, I contacted Vbout and they were able to take care of it. Now, it’s working just fine. I am thankful to you for all your efforts. You have been a great help.

2 Likes