0

I'm trying to add BugHerd (an issue tracking tool) to my Magento 2.1 project, which requires I add the following script into the <head> tag:

<script type='text/javascript'>
  (function (d, t) {
     var bh = d.createElement(t), s = d.getElementsByTagName(t)[0];
     bh.type = 'text/javascript';
     bh.src = 'https://www.bugherd.com/sidebarv2.js?apikey={my api key}';
      s.parentNode.insertBefore(bh, s);
  })(document, 'script');
</script>

There are many questions on this topic referencing old Magento versions, but I can't seem to find an updated answer. Any ideas?

Thanks!

2 Answers 2

1

Hi you can also use the backend of magento 2 website.

Just add the bugherd JS code in Content>Design>Configuration>"Your Current Store" and just like the picture insert your JS code there and save.

I hope this helps.

enter image description here

1
  • No problem, You're welcome. Mar 7, 2017 at 1:29
0

In your theme's directory, create this file: {theme_dir}/Magento_Theme/layout/default.xml with the following:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <script src="js/bugherd.js"/>
    </head>
</page>

Then you put the bugherd.js file in {theme_dir}/web/js/bugherd.js

1
  • This worked for me! Thanks for your quick response.
    – Kedmasterk
    Mar 4, 2017 at 1:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.