Get Google Analytics ID with Javascript
<p>I am trying to extract the Google analytics ID from a html document.</p>

<p>I found the following function:</p>

<pre><code>function get_UA() {

txt = document.getElementById('scripttag').value;

var matches = txt.match(/(UA-[\d-]+)/);

if (matches[1]) {

    alert(matches[1]);

}

}
</code></pre>

<p>But im getting this error:</p>

<blockquote>
  <p>TypeError: 'null' is not an object (evaluating
  'document.getElementById('scripttag').value')</p>
</blockquote>

<p>Any ideas?</p>
