noscript thowing an error on a js file

I have a code I got from google analytics to put on my site.
I want to put it in an external js file.
It has this at the begining  and it's throwing an error.
 <!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-7XRT"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager -->

How am I supposed this on a js file?
rivkamakAsked:
Who is Participating?
 
Scott Fell, EE MVEConnect With a Mentor Developer & EE ModeratorCommented:
The code belongs outside of a js file.  It should be in your html.
0
 
Shaun KlineConnect With a Mentor Lead Software EngineerCommented:
The code is for an HTML file, or a file that generates HTML, such as ASP or ASP.NET. If you are using ASP.NET with a master page, add it there.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.