On Tuesday, 29 December 2015, Maxim Dounin <<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello!<br>
<br>
On Tue, Dec 29, 2015 at 05:07:37PM +0800, 天河石 - 谢金鹏 wrote:<br>
<br>
> I like to add the following entry:<br>
><br>
><br>
>  <script type="text/javascript" async="async" src="<a href="http://www.google-analytics.com/ga.js" target="_blank">http://www.google-analytics.com/ga.js</a>"></script><br>
><br>
><br>
> in <head> section. How do I do it?<br>
<br>
Assuming you want to do it using nginx, try something like this:<br>
<br>
    sub_filter '</head>'<br>
               '<script type="text/javascript" async="async" src="<a href="http://www.google-analytics.com/ga.js" target="_blank">http://www.google-analytics.com/ga.js</a>"></script></head>';<br>
<br>
See docs here for details:<br>
<br>
<a href="http://nginx.org/en/docs/http/ngx_http_sub_module.html" target="_blank">http://nginx.org/en/docs/http/ngx_http_sub_module.html</a><br></blockquote><div><br></div><div>Here is another way to do it:</div><div><a href="https://developers.google.com/speed/pagespeed/module/filter-insert-ga">https://developers.google.com/speed/pagespeed/module/filter-insert-ga</a></div><div><br></div><div>It relies on even bigger 3rd party module that is also not included and compiler <span></span>by default.</div>