title: Google Tag Manager script Uncaught TypeError: Cannot read property 'test' of undefined
body: <p>I'm attempting to implement <a href="https://developers.google.com/tag-manager/quickstart" rel="noreferrer">the Google Tag Manager script</a> onto my page but it's throwing an error. I stripped down my html page to the bare-bones:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;script&gt;(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
        new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
        j=d.createElement(s),dl=l!='dataLayer'?'&amp;l='+l:'';j.async=true;j.src=
        'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
      })(window,document,'script','dataLayer','GTM-XXXX');&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>But I'm still seeing the following error thrown in the conole:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'test' of undefined
      at &lt;anonymous&gt;:14:12
      at gtm.js?id=GTM-XXXX:57
      at Object.Th (gtm.js?id=GTM-XXXX:59)
      at sf (gtm.js?id=GTM-XXXX:31)
      at uk.B (gtm.js?id=GTM-XXXX:90)
      at ag (gtm.js?id=GTM-XXXX:99)
      at jg (gtm.js?id=GTM-XXXX:39)
      at Array.a.push (gtm.js?id=GTM-XXXX:105)
      at Array.&lt;anonymous&gt; (gtm.js?id=GTM-XXXX:105)
      at Lf (gtm.js?id=GTM-XXXX:34)
  </code></pre>
  
  <p><a href="https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna?hl=en" rel="noreferrer">The GA Debugger Chrome extension</a> shows that the script is still "working", i.e. all the proper ga methods are firing. I'm just concerned what this error is.</p>
  
  <p>Note, I also get the same error in Firefox and Safari (the trace looks slightly different but it's the same error):</p>
  
  <pre><code>TypeError: undefined is not an object (evaluating 'tryformurls.test')
      Global Code (Script Element 2:14)
      insertBefore
      (anonymous function) (gtm.js:57:395)
      Th (gtm.js:59:209)
      sf (gtm.js:31)
      (anonymous function) (gtm.js:90:467)
      ag (gtm.js:99:263)
      jg (gtm.js:39:257)
      push (gtm.js:105:388)
      (anonymous function) (gtm.js:105:151)
      Lf (gtm.js:34:198)
      (anonymous function) (gtm.js:106:83)
      Global Code (gtm.js:108)
  </code></pre>