title: How to add Google Analytics to plotly dash app
body: <p>I built a site with python dash app and now I want to insert Google Analytics. The google javascript looks like this:</p>
  
  <pre><code>&lt;script&gt;
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  
  ga('create', 'UA-XXXXXX-1', 'auto');
  ga('send', 'pageview');
  &lt;/script&gt;
  </code></pre>
  
  <p>What I've tried so far:</p>
  
  <ol>
  <li><p><code>app.scripts.append_script({‘external_url’:‘https://mywebsite.com/assets/gtag.js’})</code></p></li>
  <li><p>Put Google Analytics script under <code>/assets</code></p></li>
  </ol>
  
  <p>None of these seem to work, since I don't see any updates in the Google Analytics dashboard.</p>
  
  <p>Should I put the script before the HTML head in dash app? How could I do this?</p>