title: add google analytics code to all pages by nginx
body: <p>I want to add my Google Analytics code to all website pages 
  i try to set</p>
  
  <pre><code>sub_filter
  </code></pre>
  
  <p>it's not working </p>
  
  <pre><code> set $tracking_id 'UA-12345678-9';
  sub_filter '&lt;/head&gt;' '&lt;script type="text/javascript"&gt;var _gaq=[["_setAccount","$tracking_id"],["_trackPageview"]];(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;g.src="//www.google-analytics.com/ga.js";s.parentNode.insertBefore(g,s)})(document,"script")&lt;/script&gt;&lt;/head&gt;';
  </code></pre>
  
  <p>and i try to use </p>
  
  <pre><code>add_before_body /file.html
  </code></pre>
  
  <p>it's give me error page not loading </p>
  
  <p>and i try to use </p>
  
  <pre><code>add_after_body /file.html
  </code></pre>
  
  <p>it's working good , but it's set code out html of page</p>