how to add <script> in <header>

Aapo Talvensaari aapo.talvensaari at gmail.com
Tue Dec 29 17:02:09 UTC 2015


On Tuesday, 29 December 2015, Maxim Dounin <mdounin at mdounin.ru> wrote:

> Hello!
>
> On Tue, Dec 29, 2015 at 05:07:37PM +0800, 天河石 - 谢金鹏 wrote:
>
> > I like to add the following entry:
> >
> >
> >  <script type="text/javascript" async="async" src="
> http://www.google-analytics.com/ga.js"></script>
> >
> >
> > in <head> section. How do I do it?
>
> Assuming you want to do it using nginx, try something like this:
>
>     sub_filter '</head>'
>                '<script type="text/javascript" async="async" src="
> http://www.google-analytics.com/ga.js"></script></head>';
>
> See docs here for details:
>
> http://nginx.org/en/docs/http/ngx_http_sub_module.html
>

Here is another way to do it:
https://developers.google.com/speed/pagespeed/module/filter-insert-ga

It relies on even bigger 3rd party module that is also not included and
compiler by default.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20151229/95f25240/attachment.html>


More information about the nginx mailing list