Skip to content

Instantly share code, notes, and snippets.

@nikolay
Created January 17, 2015 19:00
Show Gist options
  • Save nikolay/e58fb0de98acd8aed932 to your computer and use it in GitHub Desktop.
Save nikolay/e58fb0de98acd8aed932 to your computer and use it in GitHub Desktop.
Remove Google Analytics tags to improve caching
if ($args ~ (.*)utm_source=[^&]*(.*)) {
set $args $1$2;
}
if ($args ~ (.*)utm_medium=[^&]*(.*)) {
set $args $1$2;
}
if ($args ~ (.*)utm_term=[^&]*(.*)) {
set $args $1$2;
}
if ($args ~ (.*)utm_content=[^&]*(.*)) {
set $args $1$2;
}
if ($args ~ (.*)utm_id=[^&]*(.*)) {
set $args $1$2;
}
if ($args ~ (.*)utm_campaign=[^&]*(.*)) {
set $args $1$2;
}
if ($args ~ (.*)gclid=[^&]*(.*)) {
set $args $1$2;
}
# cleanup any repeated '&' introduced
if ($args ~ (.*)&&+(.*)) {
set $args $1&$2;
}
# cleanup leading '&'
if ($args ~ ^&(.*)) {
set $args $1;
}
# cleanup ending '&'
if ($args ~ (.*)&$) {
set $args $1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment