# Nginx and google analytics

**URL:** <https://www.ruby-forum.com/t/nginx-and-google-analytics/208626>\
**Category:** NGINX\
**Created:** [June 23, 2011, 12:40am UTC](https://www.ruby-forum.com/t/nginx-and-google-analytics/208626 "2011-06-23T00:40:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [June 23, 2011, 12:40am UTC](https://www.ruby-forum.com/t/nginx-and-google-analytics/208626/1 "2011-06-23T00:40:13Z")

</div>

I am trying to find the right sub\_filter settings to make nginx place  
my google analytics code on all my pages. Here is the google code:

If anyone has a suggestion, I would really appreciate it. Thanks!

Brent

---

<div class="post-metadata">

**Author:** ![bwellsnc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e8cbc/32.png) [@bwellsnc](https://www.ruby-forum.com/u/bwellsnc)\
**Post date:** [June 23, 2011, 12:48am UTC](https://www.ruby-forum.com/t/nginx-and-google-analytics/208626/2 "2011-06-23T00:48:14Z")

</div>

I think you need to call ga code from a file like below:

location / {  
sub\_filter   
‘’;  
sub\_filter\_once on;  
}

On Wednesday, June 22, 2011, bwellsnc [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> var ga = document.createElement('script'); ga.type =
> 
> ```
> 
> Brent
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–  
Joshua Parker  
Church Management System - [http://www.churchmember.us/](http://www.churchmember.us/)
