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
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.
-
No problem, You're welcome.Toto Memeng– Toto Memeng2017年03月07日 01:29:06 +00:00Commented Mar 7, 2017 at 1:29
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
-
This worked for me! Thanks for your quick response.Kedmasterk– Kedmasterk2017年03月04日 01:05:40 +00:00Commented Mar 4, 2017 at 1:05