0

i copied and pasted my hubspot js tracking code directly from the app as it says to do, but when i place in on the page in html it seems to be not clean code and might be closing out too soon, What is going on with this:

<script type="text/javascript">
    (function(d,s,i,r) {
        if (d.getElementById(i)){return;}
        var n=d.createElement(s),e=d.getElementsByTagName(s)[0];
        n.id=i;n.src='//js.hs-analytics.net/analytics/'+(Math.ceil(new Date()/r)*r)+'/12345.js';
        e.parentNode.insertBefore(n, e);
    })(document,"script","hs-analytics",300000);
</script>

It is causing any code after it to be broken and attached to this js call. I searched around an can't seem to find anything on this..

esternle
  • 33
  • 1
  • 8

2 Answers2

1

There's no error in the code, it's just that the IDE you are using is not being able to parse the code as valid syntax.

To confirm: Put your code in jsfiddle.net and click on "JSHint"

It will pop-up a message that code is valid.

Amit Singh
  • 2,267
  • 4
  • 25
  • 50
0

The HubSpot tracking code uses some foo and messes up your following code. Specifically, here: '/12345.js'

I recommend adding it as a separate file: <script src="/assets/js/hubspot.js"></script>

anonameuser22
  • 108
  • 12